Beispiel #1
0
        internal override Opcode Eval(ProcessingContext context)
        {
            context.PushFrame();
            int count = context.IterationCount;

            if (count > 0)
            {
                object o = this.variable.Evaluate(this.xsltContext);
                if (o == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QueryProcessingException(QueryProcessingError.Unexpected, SR.GetString(SR.QueryVariableNull)));
                }

                switch (this.type)
                {
                case ValueDataType.Boolean:
                    context.Push((bool)o, count);
                    break;

                case ValueDataType.Double:
                    context.Push((double)o, count);
                    break;

                case ValueDataType.String:
                    context.Push((string)o, count);
                    break;

                case ValueDataType.Sequence:
                    XPathNodeIterator iter = (XPathNodeIterator)o;
                    NodeSequence      seq  = context.CreateSequence();
                    while (iter.MoveNext())
                    {
                        SeekableXPathNavigator nav = iter.Current as SeekableXPathNavigator;
                        if (nav != null)
                        {
                            seq.Add(nav);
                        }
                        else
                        {
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QueryProcessingException(QueryProcessingError.Unexpected, SR.GetString(SR.QueryMustBeSeekable)));
                        }
                    }
                    context.Push(seq, count);
                    break;

                default:
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, SR.GetString(SR.QueryVariableTypeNotSupported, this.variable.VariableType.ToString())));
                }
            }
            return(this.next);
        }
        internal override Opcode Eval(ProcessingContext context)
        {
            context.PushFrame();
            int iterationCount = context.IterationCount;

            if (iterationCount > 0)
            {
                object obj2 = this.variable.Evaluate(this.xsltContext);
                if (obj2 == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QueryProcessingException(QueryProcessingError.Unexpected, System.ServiceModel.SR.GetString("QueryVariableNull")));
                }
                switch (this.type)
                {
                case ValueDataType.Boolean:
                    context.Push((bool)obj2, iterationCount);
                    goto Label_013A;

                case ValueDataType.Double:
                    context.Push((double)obj2, iterationCount);
                    goto Label_013A;

                case ValueDataType.Sequence:
                {
                    XPathNodeIterator iterator = (XPathNodeIterator)obj2;
                    NodeSequence      sequence = context.CreateSequence();
                    while (iterator.MoveNext())
                    {
                        SeekableXPathNavigator current = iterator.Current as SeekableXPathNavigator;
                        if (current == null)
                        {
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QueryProcessingException(QueryProcessingError.Unexpected, System.ServiceModel.SR.GetString("QueryMustBeSeekable")));
                        }
                        sequence.Add(current);
                    }
                    context.Push(sequence, iterationCount);
                    goto Label_013A;
                }

                case ValueDataType.String:
                    context.Push((string)obj2, iterationCount);
                    goto Label_013A;
                }
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, System.ServiceModel.SR.GetString("QueryVariableTypeNotSupported", new object[] { this.variable.VariableType.ToString() })));
            }
Label_013A:
            return(base.next);
        }
Beispiel #3
0
        internal static void IterateAndPushSequences(ProcessingContext context)
        {
            StackFrame sequences = context.TopSequenceArg;

            Value[] sequenceBuffer = context.Sequences;

            context.PushFrame();
            while (sequences.basePtr <= sequences.endPtr)
            {
                NodeSequence sourceSeq = sequenceBuffer[sequences.basePtr++].Sequence;
                int          count     = sourceSeq.Count;
                if (count == 0)
                {
                    context.PushSequence(NodeSequence.Empty);
                }
                else
                {
                    for (int item = 0; item < sourceSeq.Count; ++item)
                    {
                        NodeSequence newSequence = context.CreateSequence();
                        newSequence.StartNodeset();
                        newSequence.Add(ref sourceSeq.Items[item]);
                        newSequence.StopNodeset();
                        context.Push(newSequence);
                    }
                }
            }
        }
 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);
     }
 }
Beispiel #5
0
        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 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 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);
     }
 }
Beispiel #8
0
        internal static void IterateAndPushSequences(ProcessingContext context)
        {
            StackFrame topSequenceArg = context.TopSequenceArg;

            Value[] sequences = context.Sequences;
            context.PushFrame();
            while (topSequenceArg.basePtr <= topSequenceArg.endPtr)
            {
                NodeSequence sequence = sequences[topSequenceArg.basePtr++].Sequence;
                if (sequence.Count == 0)
                {
                    context.PushSequence(NodeSequence.Empty);
                }
                else
                {
                    for (int i = 0; i < sequence.Count; i++)
                    {
                        NodeSequence sequence2 = context.CreateSequence();
                        sequence2.StartNodeset();
                        sequence2.Add(ref sequence.Items[i]);
                        sequence2.StopNodeset();
                        context.Push(sequence2);
                    }
                }
            }
        }
Beispiel #9
0
        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 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 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 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 override Opcode Eval(ProcessingContext context)
 {
     context.PushFrame();
     int iterationCount = context.IterationCount;
     if (iterationCount > 0)
     {
         context.Push(this.literal, iterationCount);
     }
     return base.next;
 }
Beispiel #15
0
        internal static void BooleanFalse(ProcessingContext context)
        {
            context.PushFrame();
            int count = context.IterationCount;

            if (count > 0)
            {
                context.Push(false, count);
            }
        }
Beispiel #16
0
        internal static void BooleanTrue(ProcessingContext context)
        {
            context.PushFrame();
            int iterationCount = context.IterationCount;

            if (iterationCount > 0)
            {
                context.Push(true, iterationCount);
            }
        }
        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 void InvokeInternal(ProcessingContext context, int argCount)
        {
            context.PushFrame();
            int iterationCount = context.IterationCount;

            if (iterationCount > 0)
            {
                string action = context.Processor.Action;
                if (action == null)
                {
                    Message contextMessage = context.Processor.ContextMessage;
                    if (contextMessage == null)
                    {
                        SeekableXPathNavigator contextNode = context.Processor.ContextNode;
                        long currentPosition = contextNode.CurrentPosition;
                        action = ExtractFromNavigator(contextNode);
                        contextNode.CurrentPosition = currentPosition;
                    }
                    else
                    {
                        action = contextMessage.Headers.Action;
                    }
                    context.Processor.Action = action;
                }
                if (action == null)
                {
                    action = string.Empty;
                    context.Processor.Action = action;
                }
                if (iterationCount == 1)
                {
                    context.Push(action);
                }
                else
                {
                    context.Push(action, iterationCount);
                }
            }
        }
 internal override Opcode Eval(ProcessingContext context)
 {
     StackFrame topSequenceArg = context.TopSequenceArg;
     Value[] sequences = context.Sequences;
     context.PushFrame();
     for (int i = topSequenceArg.basePtr; i <= topSequenceArg.endPtr; i++)
     {
         NodeSequence sequence = sequences[i].Sequence;
         for (int j = 0; j < sequence.Count; j++)
         {
             NodeSequenceItem item = sequence[j];
             context.Push(item.Position == this.ordinal);
         }
     }
     return base.next;
 }
        internal override Opcode Eval(ProcessingContext context)
        {
            StackFrame sequences = context.TopSequenceArg;
            Value[] sequenceBuffer = context.Sequences;

            context.PushFrame();
            for (int i = sequences.basePtr; i <= sequences.endPtr; ++i)
            {
                NodeSequence sequence = sequenceBuffer[i].Sequence;
                for (int item = 0; item < sequence.Count; ++item)
                {
                    context.Push(sequence[item].Position == this.ordinal);
                }
            }
            return this.next;
        }
Beispiel #21
0
        internal override Opcode Eval(ProcessingContext context)
        {
            StackFrame sequences = context.TopSequenceArg;

            Value[] sequenceBuffer = context.Sequences;

            context.PushFrame();
            for (int i = sequences.basePtr; i <= sequences.endPtr; ++i)
            {
                NodeSequence sequence = sequenceBuffer[i].Sequence;
                for (int item = 0; item < sequence.Count; ++item)
                {
                    context.Push(sequence[item].Position == this.ordinal);
                }
            }
            return(this.next);
        }
 private void InvokeNonMatch(ProcessingContext context, QueryBranch branch)
 {
     context.PushFrame();
     context.Push(false, this.resultCount);
     try
     {
         context.EvalCodeBlock(branch.Branch);
     }
     catch (XPathNavigatorException exception)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception.Process(branch.Branch));
     }
     catch (NavigatorInvalidBodyAccessException exception2)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception2.Process(branch.Branch));
     }
 }
Beispiel #23
0
        internal override Opcode Eval(ProcessingContext context)
        {
            StackFrame topSequenceArg = context.TopSequenceArg;

            Value[] sequences = context.Sequences;
            context.PushFrame();
            for (int i = topSequenceArg.basePtr; i <= topSequenceArg.endPtr; i++)
            {
                NodeSequence sequence = sequences[i].Sequence;
                for (int j = 0; j < sequence.Count; j++)
                {
                    NodeSequenceItem item = sequence[j];
                    context.Push(item.Position == this.ordinal);
                }
            }
            return(base.next);
        }
        internal override void InvokeInternal(ProcessingContext context, int argCount)
        {
            context.PushFrame();
            int count = context.IterationCount;
            if (count > 0)
            {
                string to = context.Processor.ToHeader;
                if (to == null)
                {
                    Message msg = context.Processor.ContextMessage;
                    if (msg == null)
                    {
                        SeekableXPathNavigator nav = context.Processor.ContextNode;

                        long p = nav.CurrentPosition;
                        to = ExtractFromNavigator(nav);
                        nav.CurrentPosition = p;
                    }
                    else
                    {
                        Uri tempTo = msg.Headers.To;
                        if (tempTo == null)
                            to = msg.Version.Addressing.Anonymous;
                        else
                            to = tempTo.AbsoluteUri;
                    }
                    context.Processor.ToHeader = to;
                }
                context.Push(to, count);
            }
        }
 private void InitResults(ProcessingContext context)
 {
     context.PushFrame();
     context.Push(false, this.resultCount);
 }
        internal static void IterateAndPushSequences(ProcessingContext context)
        {
            StackFrame sequences = context.TopSequenceArg;
            Value[] sequenceBuffer = context.Sequences;

            context.PushFrame();
            while (sequences.basePtr <= sequences.endPtr)
            {
                NodeSequence sourceSeq = sequenceBuffer[sequences.basePtr++].Sequence;
                int count = sourceSeq.Count;
                if (count == 0)
                {
                    context.PushSequence(NodeSequence.Empty);
                }
                else
                {
                    for (int item = 0; item < sourceSeq.Count; ++item)
                    {
                        NodeSequence newSequence = context.CreateSequence();
                        newSequence.StartNodeset();
                        newSequence.Add(ref sourceSeq.Items[item]);
                        newSequence.StopNodeset();
                        context.Push(newSequence);
                    }
                }
            }
        }
        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;
        }
 private void InitResults(ProcessingContext context)
 {
     context.PushFrame();
     context.Push(false, this.resultCount);
 }
 internal static void BooleanTrue(ProcessingContext context)
 {
     context.PushFrame();
     int count = context.IterationCount;
     if (count > 0)
     {
         context.Push(true, count);
     }
 }
        internal override void InvokeInternal(ProcessingContext context, int argCount)
        {
            context.PushFrame();
            int count = context.IterationCount;
            if (count > 0)
            {
                string soap = context.Processor.SoapUri;
                if (soap == null)
                {
                    Message msg = context.Processor.ContextMessage;
                    if (msg == null)
                    {
                        SeekableXPathNavigator nav = context.Processor.ContextNode;

                        long p = nav.CurrentPosition;
                        soap = ExtractFromNavigator(nav);
                        nav.CurrentPosition = p;
                    }
                    else
                    {
                        soap = msg.Version.Envelope.Namespace;
                    }

                    context.Processor.SoapUri = soap;
                }
                context.Push(soap, count);
            }
        }
Beispiel #31
0
 void InitResults(ProcessingContext context)
 {
     context.PushFrame();
     // Push this.resultsCount booleans onto the stack, all set to false
     context.Push(false, this.resultCount);
 }
        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;
        }
Beispiel #33
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 override void InvokeInternal(ProcessingContext context, int argCount)
        {
            context.PushFrame();
            int count = context.IterationCount;
            if (count > 0)
            {
                string act = context.Processor.Action;
                if (act == null)
                {
                    Message msg = context.Processor.ContextMessage;
                    if (msg == null)
                    {
                        SeekableXPathNavigator nav = context.Processor.ContextNode;

                        long p = nav.CurrentPosition;
                        act = ExtractFromNavigator(nav);
                        nav.CurrentPosition = p;
                    }
                    else
                    {
                        act = msg.Headers.Action;
                    }
                    context.Processor.Action = act;
                }

                if (act == null)
                {
                    act = string.Empty;
                    context.Processor.Action = act;
                }

                if (count == 1)
                {
                    context.Push(act);
                }
                else
                {
                    context.Push(act, count);
                }
            }
        }
 internal override void InvokeInternal(ProcessingContext context, int argCount)
 {
     context.PushFrame();
     int count = context.IterationCount;
     if (count > 0)
     {
         context.Push(ConvertDate(DateTime.Now), count);
     }
 }
        internal override void InvokeInternal(ProcessingContext context, int argCount)
        {
            context.PushFrame();
            int count = context.IterationCount;
            if (count > 0)
            {
                string id = context.Processor.MessageId;
                if (id == null)
                {
                    Message msg = context.Processor.ContextMessage;
                    if (msg == null)
                    {
                        SeekableXPathNavigator nav = context.Processor.ContextNode;

                        long p = nav.CurrentPosition;
                        id = ExtractFromNavigator(nav);
                        nav.CurrentPosition = p;
                    }
                    else
                    {
                        UniqueId uid = msg.Headers.MessageId;
                        if (uid == null)
                            id = string.Empty;
                        else
                            id = uid.ToString();
                    }
                    context.Processor.MessageId = id;
                }
                context.Push(id, count);
            }
        }
Beispiel #37
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);
        }
 private void InvokeNonMatch(ProcessingContext context, QueryBranch branch)
 {
     context.PushFrame();
     context.Push(false, this.resultCount);
     try
     {
         context.EvalCodeBlock(branch.Branch);
     }
     catch (XPathNavigatorException exception)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception.Process(branch.Branch));
     }
     catch (NavigatorInvalidBodyAccessException exception2)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception2.Process(branch.Branch));
     }
 }
        internal override Opcode Eval(ProcessingContext context)
        {
            context.PushFrame();
            int count = context.IterationCount;
            if (count > 0)
            {
                object o = this.variable.Evaluate(this.xsltContext);
                if (o == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QueryProcessingException(QueryProcessingError.Unexpected, SR.GetString(SR.QueryVariableNull)));
                }

                switch (this.type)
                {
                    case ValueDataType.Boolean:
                        context.Push((bool)o, count);
                        break;

                    case ValueDataType.Double:
                        context.Push((double)o, count);
                        break;

                    case ValueDataType.String:
                        context.Push((string)o, count);
                        break;

                    case ValueDataType.Sequence:
                        XPathNodeIterator iter = (XPathNodeIterator)o;
                        NodeSequence seq = context.CreateSequence();
                        while (iter.MoveNext())
                        {
                            SeekableXPathNavigator nav = iter.Current as SeekableXPathNavigator;
                            if (nav != null)
                            {
                                seq.Add(nav);
                            }
                            else
                            {
                                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QueryProcessingException(QueryProcessingError.Unexpected, SR.GetString(SR.QueryMustBeSeekable)));
                            }
                        }
                        context.Push(seq, count);
                        break;

                    default:
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, SR.GetString(SR.QueryVariableTypeNotSupported, this.variable.VariableType.ToString())));
                }
            }
            return this.next;
        }
 internal static void IterateAndPushSequences(ProcessingContext context)
 {
     StackFrame topSequenceArg = context.TopSequenceArg;
     Value[] sequences = context.Sequences;
     context.PushFrame();
     while (topSequenceArg.basePtr <= topSequenceArg.endPtr)
     {
         NodeSequence sequence = sequences[topSequenceArg.basePtr++].Sequence;
         if (sequence.Count == 0)
         {
             context.PushSequence(NodeSequence.Empty);
         }
         else
         {
             for (int i = 0; i < sequence.Count; i++)
             {
                 NodeSequence sequence2 = context.CreateSequence();
                 sequence2.StartNodeset();
                 sequence2.Add(ref sequence.Items[i]);
                 sequence2.StopNodeset();
                 context.Push(sequence2);
             }
         }
     }
 }