internal override void InvokeInternal(ProcessingContext context, int argCount) { int iterationCount = context.IterationCount; context.PushSequenceFrame(); if (iterationCount > 0) { NodeSequence seq = context.CreateSequence(); seq.StartNodeset(); SeekableXPathNavigator contextNode = context.Processor.ContextNode; long currentPosition = contextNode.CurrentPosition; if (XPathMessageFunction.MoveToAddressingHeader(contextNode, "RelatesTo")) { seq.Add(contextNode); while (XPathMessageFunction.MoveToAddressingHeaderSibling(contextNode, "RelatesTo")) { seq.Add(contextNode); } } seq.StopNodeset(); context.PushSequence(seq); for (int i = 1; i < iterationCount; i++) { seq.refCount++; context.PushSequence(seq); } contextNode.CurrentPosition = currentPosition; } }
internal override Opcode Eval(ProcessingContext context) { StackFrame topSequenceArg = context.TopSequenceArg; Value[] sequences = context.Sequences; bool sequenceStackInUse = context.SequenceStackInUse; context.PushSequenceFrame(); for (int i = topSequenceArg.basePtr; i <= topSequenceArg.endPtr; i++) { NodeSequence sequence = sequences[i].Sequence; if (sequence.Count == 0) { if (!sequenceStackInUse) { context.PushSequence(NodeSequence.Empty); } } else { NodeSequenceItem[] items = sequence.Items; for (int j = 0; j < sequence.Count; j++) { SeekableXPathNavigator contextNode = items[j].GetNavigator(); NodeSequence destSequence = context.CreateSequence(); destSequence.StartNodeset(); base.criteria.Select(contextNode, destSequence); destSequence.StopNodeset(); context.PushSequence(destSequence); } } } return base.next; }
internal override void InvokeInternal(ProcessingContext context, int argCount) { StackFrame topArg = context.TopArg; SeekableXPathNavigator contextNode = context.Processor.ContextNode; long currentPosition = contextNode.CurrentPosition; while (topArg.basePtr <= topArg.endPtr) { string str = context.PeekString(topArg.basePtr); NodeSequence val = context.CreateSequence(); if (XPathMessageFunction.MoveToHeader(contextNode) && contextNode.MoveToFirstChild()) { do { long num2 = contextNode.CurrentPosition; string str2 = XPathMessageFunctionActor.ExtractFromNavigator(contextNode); contextNode.CurrentPosition = num2; if (str2 == str) { val.Add(contextNode); } } while (contextNode.MoveToNext()); } context.SetValue(context, topArg.basePtr, val); topArg.basePtr++; } contextNode.CurrentPosition = currentPosition; }
internal override Opcode Eval(ProcessingContext context) { if (!context.LoadVariable(this.expr.Variable)) { context.PushSequenceFrame(); NodeSequence seq = context.CreateSequence(); seq.Add(context.Processor.ContextNode); context.PushSequence(seq); int counterMarker = context.Processor.CounterMarker; try { this.expr.Eval(context); } catch (XPathNavigatorException exception) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception.Process(this)); } catch (NavigatorInvalidBodyAccessException exception2) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception2.Process(this)); } context.Processor.CounterMarker = counterMarker; context.PopSequenceFrame(); context.PopSequenceFrame(); context.LoadVariable(this.expr.Variable); } return base.next; }
internal override Opcode Eval(ProcessingContext context) { context.PushContextSequenceFrame(); NodeSequence seq = context.CreateSequence(); seq.StartNodeset(); seq.Add(context.Processor.ContextNode); seq.StopNodeset(); context.PushSequence(seq); return this.next; }
internal override Opcode Eval(ProcessingContext context) { StackFrame topSequenceArg = context.TopSequenceArg; SeekableXPathNavigator contextNode = null; Value[] sequences = context.Sequences; for (int i = topSequenceArg.basePtr; i <= topSequenceArg.endPtr; i++) { NodeSequence sequence = sequences[i].Sequence; int count = sequence.Count; if (count == 0) { context.ReplaceSequenceAt(i, NodeSequence.Empty); context.ReleaseSequence(sequence); } else { NodeSequenceItem[] items = sequence.Items; if (sequence.CanReuse(context)) { contextNode = items[0].GetNavigator(); sequence.Clear(); sequence.StartNodeset(); this.criteria.Select(contextNode, sequence); sequence.StopNodeset(); } else { NodeSequence destSequence = null; for (int j = 0; j < count; j++) { contextNode = items[j].GetNavigator(); if (destSequence == null) { destSequence = context.CreateSequence(); } destSequence.StartNodeset(); this.criteria.Select(contextNode, destSequence); destSequence.StopNodeset(); } context.ReplaceSequenceAt(i, (destSequence != null) ? destSequence : NodeSequence.Empty); context.ReleaseSequence(sequence); } } } return base.next; }
internal override Opcode Eval(ProcessingContext context) { Value[] values = context.Values; StackFrame topArg = context.TopArg; for (int i = topArg.basePtr; i <= topArg.endPtr; i++) { NodeSequence sequence = values[i].Sequence; NodeSequence val = context.CreateSequence(); for (int j = 0; j < sequence.Count; j++) { NodeSequenceItem item = sequence[j]; val.AddCopy(ref item); } val.Merge(); context.SetValue(context, i, val); } return base.next; }
internal override Opcode Eval(ProcessingContext context) { Value[] values = context.Values; StackFrame topArg = context.TopArg; for (int i = topArg.basePtr; i <= topArg.endPtr; i++) { NodeSequence sequence = values[i].Sequence; NodeSequence val = context.CreateSequence(); for (int j = 0; j < sequence.Count; j++) { NodeSequenceItem item = sequence[j]; val.AddCopy(ref item); } val.Merge(); context.SetValue(context, i, val); } return(base.next); }
/// <summary> /// Union algorithm: /// 1. Add both sequences of items to a newly created sequence /// 2. Sort the items based on document position /// 3. Renumber positions in this new unionized sequence /// </summary> internal NodeSequence Union(ProcessingContext context, NodeSequence otherSeq) { NodeSequence seq = context.CreateSequence(); SortedBuffer <QueryNode, QueryNodeComparer> buff = new SortedBuffer <QueryNode, QueryNodeComparer>(staticQueryNodeComparerInstance); for (int i = 0; i < this.count; ++i) { buff.Add(this.items[i].Node); } for (int i = 0; i < otherSeq.count; ++i) { buff.Add(otherSeq.items[i].Node); } for (int i = 0; i < buff.Count; ++i) { seq.Add(buff[i]); } seq.RenumberItems(); return(seq); /* * // PERF, [....], I think we can do the merge ourselves and avoid the sort. * // Need to verify that the sequences are always in document order. * for(int i = 0; i < this.count; ++i) * { * seq.AddCopy(ref this.items[i]); * } * * for(int i = 0; i < otherSeq.count; ++i) * { * seq.AddCopy(ref otherSeq.items[i]); * } * * seq.SortNodes(); * seq.RemoveDuplicates(); * * return seq; */ }
internal NodeSequence Union(ProcessingContext context, NodeSequence otherSeq) { NodeSequence sequence = context.CreateSequence(); SortedBuffer <QueryNode, QueryNodeComparer> buffer = new SortedBuffer <QueryNode, QueryNodeComparer>(staticQueryNodeComparerInstance); for (int i = 0; i < this.count; i++) { buffer.Add(this.items[i].Node); } for (int j = 0; j < otherSeq.count; j++) { buffer.Add(otherSeq.items[j].Node); } for (int k = 0; k < buffer.Count; k++) { sequence.Add(buffer[k]); } sequence.RenumberItems(); return(sequence); }
internal override Opcode Eval(ProcessingContext context) { int iterationCount = context.IterationCount; Opcode next = base.next; context.PushSequenceFrame(); NodeSequence empty = context.CreateSequence(); if ((base.next != null) && ((base.next.Flags & OpcodeFlags.CompressableSelect) != OpcodeFlags.None)) { SeekableXPathNavigator contextNode = context.Processor.ContextNode; contextNode.MoveToRoot(); next = base.next.Eval(empty, contextNode); while ((next != null) && ((next.Flags & OpcodeFlags.CompressableSelect) != OpcodeFlags.None)) { next = next.Next; } } else { empty.StartNodeset(); SeekableXPathNavigator node = context.Processor.ContextNode; node.MoveToRoot(); empty.Add(node); empty.StopNodeset(); } if (empty.Count == 0) { context.ReleaseSequence(empty); empty = NodeSequence.Empty; } for (int i = 0; i < iterationCount; i++) { context.PushSequence(empty); } if (iterationCount > 1) { empty.refCount += iterationCount - 1; } return(next); }
internal override Opcode Eval(ProcessingContext context) { int iterationCount = context.IterationCount; Opcode next = base.next; context.PushSequenceFrame(); NodeSequence empty = context.CreateSequence(); if ((base.next != null) && ((base.next.Flags & OpcodeFlags.CompressableSelect) != OpcodeFlags.None)) { SeekableXPathNavigator contextNode = context.Processor.ContextNode; contextNode.MoveToRoot(); next = base.next.Eval(empty, contextNode); while ((next != null) && ((next.Flags & OpcodeFlags.CompressableSelect) != OpcodeFlags.None)) { next = next.Next; } } else { empty.StartNodeset(); SeekableXPathNavigator node = context.Processor.ContextNode; node.MoveToRoot(); empty.Add(node); empty.StopNodeset(); } if (empty.Count == 0) { context.ReleaseSequence(empty); empty = NodeSequence.Empty; } for (int i = 0; i < iterationCount; i++) { context.PushSequence(empty); } if (iterationCount > 1) { empty.refCount += iterationCount - 1; } return next; }
internal override Opcode Eval(ProcessingContext context) { StackFrame topSequenceArg = context.TopSequenceArg; Value[] values = context.Values; StackFrame topArg = context.TopArg; Value[] sequences = context.Sequences; context.PushSequenceFrame(); for (int i = topSequenceArg.basePtr; i <= topSequenceArg.endPtr; i++) { NodeSequence sequence = sequences[i].Sequence; if (sequence.Count > 0) { NodeSequenceItem[] items = sequence.Items; NodeSequence sequence2 = null; int basePtr = topArg.basePtr; for (int j = 0; basePtr <= topArg.endPtr; j++) { if (this.test == values[basePtr].Boolean) { if (sequence2 == null) { sequence2 = context.CreateSequence(); } sequence2.AddCopy(ref items[j], NodeSequence.GetContextSize(sequence, j)); } else if (items[j].Last && (sequence2 != null)) { sequence2.Items[sequence2.Count - 1].Last = true; } basePtr++; } context.PushSequence((sequence2 == null) ? NodeSequence.Empty : sequence2); sequence2 = null; } } return(base.next); }
internal override Opcode Eval(ProcessingContext context) { Value[] values = context.Values; StackFrame arg = context.TopArg; for (int i = arg.basePtr; i <= arg.endPtr; ++i) { Fx.Assert(ValueDataType.Sequence == values[i].Type, ""); NodeSequence seq = values[i].Sequence; NodeSequence newSeq = context.CreateSequence(); for (int j = 0; j < seq.Count; ++j) { NodeSequenceItem item = seq[j]; newSeq.AddCopy(ref item); } newSeq.Merge(); context.SetValue(context, i, newSeq); } return(this.next); }
internal override Opcode Eval(ProcessingContext context) { StackFrame topSequenceArg = context.TopSequenceArg; Value[] values = context.Values; StackFrame topArg = context.TopArg; Value[] sequences = context.Sequences; context.PushSequenceFrame(); for (int i = topSequenceArg.basePtr; i <= topSequenceArg.endPtr; i++) { NodeSequence sequence = sequences[i].Sequence; if (sequence.Count > 0) { NodeSequenceItem[] items = sequence.Items; NodeSequence sequence2 = null; int basePtr = topArg.basePtr; for (int j = 0; basePtr <= topArg.endPtr; j++) { if (this.test == values[basePtr].Boolean) { if (sequence2 == null) { sequence2 = context.CreateSequence(); } sequence2.AddCopy(ref items[j], NodeSequence.GetContextSize(sequence, j)); } else if (items[j].Last && (sequence2 != null)) { sequence2.Items[sequence2.Count - 1].Last = true; } basePtr++; } context.PushSequence((sequence2 == null) ? NodeSequence.Empty : sequence2); sequence2 = null; } } return base.next; }
internal override void InvokeInternal(ProcessingContext context, int argCount) { int iterationCount = context.IterationCount; context.PushSequenceFrame(); if (iterationCount > 0) { NodeSequence seq = context.CreateSequence(); seq.StartNodeset(); SeekableXPathNavigator contextNode = context.Processor.ContextNode; long currentPosition = contextNode.CurrentPosition; if (XPathMessageFunction.MoveToHeader(contextNode)) { seq.Add(contextNode); } contextNode.CurrentPosition = currentPosition; seq.StopNodeset(); context.PushSequence(seq); for (int i = 1; i < iterationCount; i++) { context.PushSequence(seq); } } }
internal override void EvalSpecial(ProcessingContext context) { int marker = context.Processor.CounterMarker; if (!context.LoadVariable(this.var)) { XPathMessageContext.HeaderFun.InvokeInternal(context, 0); context.SaveVariable(this.var, context.Processor.ElapsedCount(marker)); } // WS, Microsoft, see if we can put this array in the processor to save // an allocation. Perhaps we can use the variables slot we're going to fill NodeSequence[] childSequences = new NodeSequence[this.children.Count]; NodeSequence seq = context.Sequences[context.TopSequenceArg.basePtr].Sequence; for (int i = 0; i < this.children.Count; ++i) { childSequences[i] = context.CreateSequence(); childSequences[i].StartNodeset(); } // Perform the index SeekableXPathNavigator nav = seq[0].GetNavigator(); if (nav.MoveToFirstChild()) { do { if (nav.NodeType == XPathNodeType.Element) { List <SubExpr> lst; string name = nav.LocalName; string ns = nav.NamespaceURI; Dictionary <string, List <SubExpr> > nextLookup; if (this.nameLookup.TryGetValue(ns, out nextLookup)) { if (nextLookup.TryGetValue(name, out lst)) { for (int i = 0; i < lst.Count; ++i) { childSequences[this.indexLookup[lst[i]].i].Add(nav); } } if (nextLookup.TryGetValue(QueryDataModel.Wildcard, out lst)) { for (int i = 0; i < lst.Count; ++i) { childSequences[this.indexLookup[lst[i]].i].Add(nav); } } } if (this.nameLookup.TryGetValue(QueryDataModel.Wildcard, out nextLookup)) { if (nextLookup.TryGetValue(QueryDataModel.Wildcard, out lst)) { for (int i = 0; i < lst.Count; ++i) { childSequences[this.indexLookup[lst[i]].i].Add(nav); } } } } } while (nav.MoveToNext()); } int secondMarker = context.Processor.CounterMarker; for (int i = 0; i < this.children.Count; ++i) { if (this.children[i].useSpecial) { childSequences[i].StopNodeset(); context.Processor.CounterMarker = secondMarker; context.PushSequenceFrame(); context.PushSequence(childSequences[i]); Opcode op = this.children[i].FirstOp.Next; while (op != null) { op = op.Eval(context); } context.SaveVariable(this.children[i].var, context.Processor.ElapsedCount(marker)); context.PopSequenceFrame(); } else { context.ReleaseSequence(childSequences[i]); //context.SetVariable(this.children[i].Variable, null, 0); } } context.Processor.CounterMarker = marker; }
internal override void EvalSpecial(ProcessingContext context) { int counterMarker = context.Processor.CounterMarker; if (!context.LoadVariable(base.var)) { XPathMessageContext.HeaderFun.InvokeInternal(context, 0); context.SaveVariable(base.var, context.Processor.ElapsedCount(counterMarker)); } NodeSequence[] sequenceArray = new NodeSequence[base.children.Count]; NodeSequence sequence = context.Sequences[context.TopSequenceArg.basePtr].Sequence; for (int i = 0; i < base.children.Count; i++) { sequenceArray[i] = context.CreateSequence(); sequenceArray[i].StartNodeset(); } SeekableXPathNavigator node = sequence[0].GetNavigator(); if (node.MoveToFirstChild()) { do { if (node.NodeType == XPathNodeType.Element) { List<SubExpr> list; Dictionary<string, List<SubExpr>> dictionary; string localName = node.LocalName; string namespaceURI = node.NamespaceURI; if (this.nameLookup.TryGetValue(namespaceURI, out dictionary)) { if (dictionary.TryGetValue(localName, out list)) { for (int k = 0; k < list.Count; k++) { sequenceArray[this.indexLookup[list[k]].i].Add(node); } } if (dictionary.TryGetValue(QueryDataModel.Wildcard, out list)) { for (int m = 0; m < list.Count; m++) { sequenceArray[this.indexLookup[list[m]].i].Add(node); } } } if (this.nameLookup.TryGetValue(QueryDataModel.Wildcard, out dictionary) && dictionary.TryGetValue(QueryDataModel.Wildcard, out list)) { for (int n = 0; n < list.Count; n++) { sequenceArray[this.indexLookup[list[n]].i].Add(node); } } } } while (node.MoveToNext()); } int num6 = context.Processor.CounterMarker; for (int j = 0; j < base.children.Count; j++) { if (base.children[j].useSpecial) { sequenceArray[j].StopNodeset(); context.Processor.CounterMarker = num6; context.PushSequenceFrame(); context.PushSequence(sequenceArray[j]); for (Opcode opcode = base.children[j].FirstOp.Next; opcode != null; opcode = opcode.Eval(context)) { } context.SaveVariable(base.children[j].var, context.Processor.ElapsedCount(counterMarker)); context.PopSequenceFrame(); } else { context.ReleaseSequence(sequenceArray[j]); } } context.Processor.CounterMarker = counterMarker; }
internal override Opcode Eval(ProcessingContext context) { // The query processor object also serves as the query document root int iterationCount = context.IterationCount; Opcode returnOpcode = this.next; // A root is always an initial step context.PushSequenceFrame(); NodeSequence seq = context.CreateSequence(); if (this.next != null && 0 != (this.next.Flags & OpcodeFlags.CompressableSelect)) { SeekableXPathNavigator node = context.Processor.ContextNode; node.MoveToRoot(); returnOpcode = this.next.Eval(seq, node); while (returnOpcode != null && 0 != (returnOpcode.Flags & OpcodeFlags.CompressableSelect)) { returnOpcode = returnOpcode.Next; } } else { // Roots do not have any qnames.. seq.StartNodeset(); SeekableXPathNavigator node = context.Processor.ContextNode; node.MoveToRoot(); seq.Add(node); seq.StopNodeset(); } if (seq.Count == 0) { context.ReleaseSequence(seq); seq = NodeSequence.Empty; } for (int i = 0; i < iterationCount; ++i) { context.PushSequence(seq); } if (iterationCount > 1) seq.refCount += iterationCount - 1; return returnOpcode; }
internal override Opcode Eval(ProcessingContext context) { StackFrame topFrame = context.TopSequenceArg; Value[] sequences = context.Sequences; bool wasInUse = context.SequenceStackInUse; context.PushSequenceFrame(); for (int i = topFrame.basePtr; i <= topFrame.endPtr; ++i) { NodeSequence sourceSeq = sequences[i].Sequence; int count = sourceSeq.Count; if (count == 0) { // Empty sequence. // Since there are no nodes in the sequence, we will track this sequence also // using an empty sequence if (!wasInUse) context.PushSequence(NodeSequence.Empty); } else { NodeSequenceItem[] items = sourceSeq.Items; for (int item = 0; item < sourceSeq.Count; ++item) { SeekableXPathNavigator node = items[item].GetNavigator(); Fx.Assert(null != node, ""); NodeSequence newSeq = context.CreateSequence(); newSeq.StartNodeset(); this.criteria.Select(node, newSeq); newSeq.StopNodeset(); context.PushSequence(newSeq); } } } return this.next; }
internal override void EvalSpecial(ProcessingContext context) { int counterMarker = context.Processor.CounterMarker; if (!context.LoadVariable(base.var)) { XPathMessageContext.HeaderFun.InvokeInternal(context, 0); context.SaveVariable(base.var, context.Processor.ElapsedCount(counterMarker)); } NodeSequence[] sequenceArray = new NodeSequence[base.children.Count]; NodeSequence sequence = context.Sequences[context.TopSequenceArg.basePtr].Sequence; for (int i = 0; i < base.children.Count; i++) { sequenceArray[i] = context.CreateSequence(); sequenceArray[i].StartNodeset(); } SeekableXPathNavigator node = sequence[0].GetNavigator(); if (node.MoveToFirstChild()) { do { if (node.NodeType == XPathNodeType.Element) { List <SubExpr> list; Dictionary <string, List <SubExpr> > dictionary; string localName = node.LocalName; string namespaceURI = node.NamespaceURI; if (this.nameLookup.TryGetValue(namespaceURI, out dictionary)) { if (dictionary.TryGetValue(localName, out list)) { for (int k = 0; k < list.Count; k++) { sequenceArray[this.indexLookup[list[k]].i].Add(node); } } if (dictionary.TryGetValue(QueryDataModel.Wildcard, out list)) { for (int m = 0; m < list.Count; m++) { sequenceArray[this.indexLookup[list[m]].i].Add(node); } } } if (this.nameLookup.TryGetValue(QueryDataModel.Wildcard, out dictionary) && dictionary.TryGetValue(QueryDataModel.Wildcard, out list)) { for (int n = 0; n < list.Count; n++) { sequenceArray[this.indexLookup[list[n]].i].Add(node); } } } }while (node.MoveToNext()); } int num6 = context.Processor.CounterMarker; for (int j = 0; j < base.children.Count; j++) { if (base.children[j].useSpecial) { sequenceArray[j].StopNodeset(); context.Processor.CounterMarker = num6; context.PushSequenceFrame(); context.PushSequence(sequenceArray[j]); for (Opcode opcode = base.children[j].FirstOp.Next; opcode != null; opcode = opcode.Eval(context)) { } context.SaveVariable(base.children[j].var, context.Processor.ElapsedCount(counterMarker)); context.PopSequenceFrame(); } else { context.ReleaseSequence(sequenceArray[j]); } } context.Processor.CounterMarker = counterMarker; }
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 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) { int count = context.IterationCount; context.PushSequenceFrame(); if (count > 0) { NodeSequence seq = context.CreateSequence(); seq.StartNodeset(); SeekableXPathNavigator nav = context.Processor.ContextNode; long p = nav.CurrentPosition; if (MoveToBody(nav)) { seq.Add(nav); } nav.CurrentPosition = p; seq.StopNodeset(); context.PushSequence(seq); for (int i = 1; i < count; ++i) { seq.refCount++; context.PushSequence(seq); } } }
internal NodeSequence Union(ProcessingContext context, NodeSequence otherSeq) { NodeSequence sequence = context.CreateSequence(); SortedBuffer<QueryNode, QueryNodeComparer> buffer = new SortedBuffer<QueryNode, QueryNodeComparer>(staticQueryNodeComparerInstance); for (int i = 0; i < this.count; i++) { buffer.Add(this.items[i].Node); } for (int j = 0; j < otherSeq.count; j++) { buffer.Add(otherSeq.items[j].Node); } for (int k = 0; k < buffer.Count; k++) { sequence.Add(buffer[k]); } sequence.RenumberItems(); return sequence; }
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 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 EvalSpecial(ProcessingContext context) { int marker = context.Processor.CounterMarker; if (!context.LoadVariable(this.var)) { XPathMessageContext.HeaderFun.InvokeInternal(context, 0); context.SaveVariable(this.var, context.Processor.ElapsedCount(marker)); } // WS, [....], see if we can put this array in the processor to save // an allocation. Perhaps we can use the variables slot we're going to fill NodeSequence[] childSequences = new NodeSequence[this.children.Count]; NodeSequence seq = context.Sequences[context.TopSequenceArg.basePtr].Sequence; for (int i = 0; i < this.children.Count; ++i) { childSequences[i] = context.CreateSequence(); childSequences[i].StartNodeset(); } // Perform the index SeekableXPathNavigator nav = seq[0].GetNavigator(); if (nav.MoveToFirstChild()) { do { if (nav.NodeType == XPathNodeType.Element) { List<SubExpr> lst; string name = nav.LocalName; string ns = nav.NamespaceURI; Dictionary<string, List<SubExpr>> nextLookup; if (this.nameLookup.TryGetValue(ns, out nextLookup)) { if (nextLookup.TryGetValue(name, out lst)) { for (int i = 0; i < lst.Count; ++i) { childSequences[this.indexLookup[lst[i]].i].Add(nav); } } if (nextLookup.TryGetValue(QueryDataModel.Wildcard, out lst)) { for (int i = 0; i < lst.Count; ++i) { childSequences[this.indexLookup[lst[i]].i].Add(nav); } } } if (this.nameLookup.TryGetValue(QueryDataModel.Wildcard, out nextLookup)) { if (nextLookup.TryGetValue(QueryDataModel.Wildcard, out lst)) { for (int i = 0; i < lst.Count; ++i) { childSequences[this.indexLookup[lst[i]].i].Add(nav); } } } } } while (nav.MoveToNext()); } int secondMarker = context.Processor.CounterMarker; for (int i = 0; i < this.children.Count; ++i) { if (this.children[i].useSpecial) { childSequences[i].StopNodeset(); context.Processor.CounterMarker = secondMarker; context.PushSequenceFrame(); context.PushSequence(childSequences[i]); Opcode op = this.children[i].FirstOp.Next; while (op != null) { op = op.Eval(context); } context.SaveVariable(this.children[i].var, context.Processor.ElapsedCount(marker)); context.PopSequenceFrame(); } else { context.ReleaseSequence(childSequences[i]); //context.SetVariable(this.children[i].Variable, null, 0); } } context.Processor.CounterMarker = marker; }
internal 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 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); } } } }
internal override Opcode Eval(ProcessingContext context) { Value[] values = context.Values; StackFrame arg = context.TopArg; for (int i = arg.basePtr; i <= arg.endPtr; ++i) { Fx.Assert(ValueDataType.Sequence == values[i].Type, ""); NodeSequence seq = values[i].Sequence; NodeSequence newSeq = context.CreateSequence(); for (int j = 0; j < seq.Count; ++j) { NodeSequenceItem item = seq[j]; newSeq.AddCopy(ref item); } newSeq.Merge(); context.SetValue(context, i, newSeq); } return this.next; }
internal override Opcode Eval(ProcessingContext context) { StackFrame topFrame = context.TopSequenceArg; SeekableXPathNavigator node = null; Value[] sequences = context.Sequences; for (int i = topFrame.basePtr; i <= topFrame.endPtr; ++i) { // Each NodeSequence will generate a new one, but only if the source FilterSequence isn't empty // If the source FilterSequence is empty, release it and replace it with an empty sequence NodeSequence sourceSeq = sequences[i].Sequence; int sourceSeqCount = sourceSeq.Count; if (sourceSeqCount == 0) { context.ReplaceSequenceAt(i, NodeSequence.Empty); context.ReleaseSequence(sourceSeq); } else { NodeSequenceItem[] items = sourceSeq.Items; if (sourceSeq.CanReuse(context)) { node = items[0].GetNavigator(); sourceSeq.Clear(); sourceSeq.StartNodeset(); this.criteria.Select(node, sourceSeq); sourceSeq.StopNodeset(); } else { NodeSequence newSeq = null; for (int item = 0; item < sourceSeqCount; ++item) { node = items[item].GetNavigator(); Fx.Assert(null != node, ""); if (null == newSeq) { newSeq = context.CreateSequence(); } newSeq.StartNodeset(); this.criteria.Select(node, newSeq); newSeq.StopNodeset(); } context.ReplaceSequenceAt(i, (null != newSeq) ? newSeq : NodeSequence.Empty); context.ReleaseSequence(sourceSeq); } } } return this.next; }
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) { 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); }