private void SelectDescendants(SeekableXPathNavigator contextNode, NodeSequence destSequence) { int num = 1; if (contextNode.MoveToFirstChild()) { while (num > 0) { if (this.MatchQName(contextNode)) { destSequence.Add(contextNode); } if (contextNode.MoveToFirstChild()) { num++; } else if (!contextNode.MoveToNext()) { while (num > 0) { contextNode.MoveToParent(); num--; if (contextNode.MoveToNext()) { break; } } } } } }
internal Opcode Select(SeekableXPathNavigator contextNode, NodeSequence destSequence, SelectOpcode next) { Opcode opcode = next.Next; switch (this.type) { case QueryNodeType.Root: contextNode.MoveToRoot(); return(next.Eval(destSequence, contextNode)); case QueryNodeType.Element: if (contextNode.MoveToFirstChild()) { do { if ((XPathNodeType.Element == contextNode.NodeType) && this.MatchQName(contextNode)) { long currentPosition = contextNode.CurrentPosition; opcode = next.Eval(destSequence, contextNode); contextNode.CurrentPosition = currentPosition; } }while (contextNode.MoveToNext()); } return(opcode); case QueryNodeType.ChildNodes: if (contextNode.MoveToFirstChild()) { do { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } }while (contextNode.MoveToNext()); } return(opcode); } if (QueryAxisType.Self != this.axis.Type) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected)); } if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { long num = contextNode.CurrentPosition; opcode = next.Eval(destSequence, contextNode); contextNode.CurrentPosition = num; } return(opcode); }
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; }
void SelectDescendants(SeekableXPathNavigator contextNode, NodeSequence destSequence) { int level = 1; if (!contextNode.MoveToFirstChild()) { return; } while (level > 0) { // Don't need type check. All child nodes allowed. if (this.MatchQName(contextNode)) { destSequence.Add(contextNode); } if (contextNode.MoveToFirstChild()) { ++level; } else if (contextNode.MoveToNext()) { } else { while (level > 0) { contextNode.MoveToParent(); --level; if (contextNode.MoveToNext()) { break; } } } } }
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 Opcode Select(SeekableXPathNavigator contextNode, NodeSequence destSequence, SelectOpcode next) { Opcode returnOpcode = next.Next; switch (this.type) { default: if (QueryAxisType.Self == this.axis.Type) { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { long position = contextNode.CurrentPosition; returnOpcode = next.Eval(destSequence, contextNode); contextNode.CurrentPosition = position; } } else { throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected)); } break; case QueryNodeType.ChildNodes: // Select children of arbitrary type off the context node if (contextNode.MoveToFirstChild()) { do { // Select the node if its type and qname matches if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } } while (contextNode.MoveToNext()); } break; case QueryNodeType.Element: // Select child elements if (contextNode.MoveToFirstChild()) { do { // Children could have non element nodes in line // Select the node if it is an element and the qname matches if (XPathNodeType.Element == contextNode.NodeType && this.MatchQName(contextNode)) { long position = contextNode.CurrentPosition; returnOpcode = next.Eval(destSequence, contextNode); contextNode.CurrentPosition = position; } } while (contextNode.MoveToNext()); } break; case QueryNodeType.Root: contextNode.MoveToRoot(); returnOpcode = next.Eval(destSequence, contextNode); break; } return returnOpcode; }
internal void Select(SeekableXPathNavigator contextNode, NodeSequence destSequence) { switch (this.type) { default: if (QueryAxisType.Self == this.axis.Type) { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } } else if (QueryAxisType.Descendant == this.axis.Type) { SelectDescendants(contextNode, destSequence); } else if (QueryAxisType.DescendantOrSelf == this.axis.Type) { destSequence.Add(contextNode); SelectDescendants(contextNode, destSequence); } else if (QueryAxisType.Child == this.axis.Type) { // Select children of arbitrary type off the context node if (contextNode.MoveToFirstChild()) { do { // Select the node if its type and qname matches if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } } while (contextNode.MoveToNext()); } } else if (QueryAxisType.Attribute == this.axis.Type) { if (contextNode.MoveToFirstAttribute()) { do { // Select the node if its type and qname matches if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); // you can't have multiple instances of an attibute with the same qname // Stop once one was found // UNLESS WE HAVE A WILDCARD OFCOURSE! if (0 == (this.qnameType & NodeQNameType.Wildcard)) { break; } } } while (contextNode.MoveToNextAttribute()); } } else { throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected)); } break; case QueryNodeType.Attribute: // Select attributes off the context Node if (contextNode.MoveToFirstAttribute()) { do { if (this.MatchQName(contextNode)) { destSequence.Add(contextNode); // you can't have multiple instances of an attibute with the same qname // Stop once one was found // UNLESS WE HAVE A WILDCARD OFCOURSE! if (0 == (this.qnameType & NodeQNameType.Wildcard)) { break; } } } while (contextNode.MoveToNextAttribute()); } break; case QueryNodeType.ChildNodes: if (QueryAxisType.Descendant == this.axis.Type) { // Select descendants of arbitrary type off the context node SelectDescendants(contextNode, destSequence); } else { // Select children of arbitrary type off the context node if (contextNode.MoveToFirstChild()) { do { // Select the node if its type and qname matches if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } } while (contextNode.MoveToNext()); } } break; case QueryNodeType.Element: if (QueryAxisType.Descendant == this.axis.Type) { // Select descendants of arbitrary type off the context node SelectDescendants(contextNode, destSequence); } else if (QueryAxisType.DescendantOrSelf == this.axis.Type) { destSequence.Add(contextNode); SelectDescendants(contextNode, destSequence); } else if (contextNode.MoveToFirstChild()) { do { // Children could have non element nodes in line // Select the node if it is an element and the qname matches if (XPathNodeType.Element == contextNode.NodeType && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } } while (contextNode.MoveToNext()); } break; case QueryNodeType.Root: contextNode.MoveToRoot(); destSequence.Add(contextNode); break; case QueryNodeType.Text: // Select child text nodes if (contextNode.MoveToFirstChild()) { do { // Select the node if its type matches // Can't just do a comparison to XPathNodeType.Text since whitespace nodes // count as text if (this.MatchType(contextNode)) { destSequence.Add(contextNode); } } while (contextNode.MoveToNext()); } break; } }
internal Opcode Select(SeekableXPathNavigator contextNode, NodeSequence destSequence, SelectOpcode next) { Opcode returnOpcode = next.Next; switch (this.type) { default: if (QueryAxisType.Self == this.axis.Type) { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { long position = contextNode.CurrentPosition; returnOpcode = next.Eval(destSequence, contextNode); contextNode.CurrentPosition = position; } } else { throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected)); } break; case QueryNodeType.ChildNodes: // Select children of arbitrary type off the context node if (contextNode.MoveToFirstChild()) { do { // Select the node if its type and qname matches if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } }while (contextNode.MoveToNext()); } break; case QueryNodeType.Element: // Select child elements if (contextNode.MoveToFirstChild()) { do { // Children could have non element nodes in line // Select the node if it is an element and the qname matches if (XPathNodeType.Element == contextNode.NodeType && this.MatchQName(contextNode)) { long position = contextNode.CurrentPosition; returnOpcode = next.Eval(destSequence, contextNode); contextNode.CurrentPosition = position; } } while (contextNode.MoveToNext()); } break; case QueryNodeType.Root: contextNode.MoveToRoot(); returnOpcode = next.Eval(destSequence, contextNode); break; } return(returnOpcode); }
internal void Select(SeekableXPathNavigator contextNode, NodeSequence destSequence) { switch (this.type) { default: if (QueryAxisType.Self == this.axis.Type) { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } } else if (QueryAxisType.Descendant == this.axis.Type) { SelectDescendants(contextNode, destSequence); } else if (QueryAxisType.DescendantOrSelf == this.axis.Type) { destSequence.Add(contextNode); SelectDescendants(contextNode, destSequence); } else if (QueryAxisType.Child == this.axis.Type) { // Select children of arbitrary type off the context node if (contextNode.MoveToFirstChild()) { do { // Select the node if its type and qname matches if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } }while (contextNode.MoveToNext()); } } else if (QueryAxisType.Attribute == this.axis.Type) { if (contextNode.MoveToFirstAttribute()) { do { // Select the node if its type and qname matches if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); // you can't have multiple instances of an attibute with the same qname // Stop once one was found // UNLESS WE HAVE A WILDCARD OFCOURSE! if (0 == (this.qnameType & NodeQNameType.Wildcard)) { break; } } }while (contextNode.MoveToNextAttribute()); } } else { throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected)); } break; case QueryNodeType.Attribute: // Select attributes off the context Node if (contextNode.MoveToFirstAttribute()) { do { if (this.MatchQName(contextNode)) { destSequence.Add(contextNode); // you can't have multiple instances of an attibute with the same qname // Stop once one was found // UNLESS WE HAVE A WILDCARD OFCOURSE! if (0 == (this.qnameType & NodeQNameType.Wildcard)) { break; } } }while (contextNode.MoveToNextAttribute()); } break; case QueryNodeType.ChildNodes: if (QueryAxisType.Descendant == this.axis.Type) { // Select descendants of arbitrary type off the context node SelectDescendants(contextNode, destSequence); } else { // Select children of arbitrary type off the context node if (contextNode.MoveToFirstChild()) { do { // Select the node if its type and qname matches if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } }while (contextNode.MoveToNext()); } } break; case QueryNodeType.Element: if (QueryAxisType.Descendant == this.axis.Type) { // Select descendants of arbitrary type off the context node SelectDescendants(contextNode, destSequence); } else if (QueryAxisType.DescendantOrSelf == this.axis.Type) { destSequence.Add(contextNode); SelectDescendants(contextNode, destSequence); } else if (contextNode.MoveToFirstChild()) { do { // Children could have non element nodes in line // Select the node if it is an element and the qname matches if (XPathNodeType.Element == contextNode.NodeType && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } }while (contextNode.MoveToNext()); } break; case QueryNodeType.Root: contextNode.MoveToRoot(); destSequence.Add(contextNode); break; case QueryNodeType.Text: // Select child text nodes if (contextNode.MoveToFirstChild()) { do { // Select the node if its type matches // Can't just do a comparison to XPathNodeType.Text since whitespace nodes // count as text if (this.MatchType(contextNode)) { destSequence.Add(contextNode); } }while (contextNode.MoveToNext()); } break; } }
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 Opcode Select(SeekableXPathNavigator contextNode, NodeSequence destSequence, SelectOpcode next) { Opcode opcode = next.Next; switch (this.type) { case QueryNodeType.Root: contextNode.MoveToRoot(); return next.Eval(destSequence, contextNode); case QueryNodeType.Element: if (contextNode.MoveToFirstChild()) { do { if ((XPathNodeType.Element == contextNode.NodeType) && this.MatchQName(contextNode)) { long currentPosition = contextNode.CurrentPosition; opcode = next.Eval(destSequence, contextNode); contextNode.CurrentPosition = currentPosition; } } while (contextNode.MoveToNext()); } return opcode; case QueryNodeType.ChildNodes: if (contextNode.MoveToFirstChild()) { do { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } } while (contextNode.MoveToNext()); } return opcode; } if (QueryAxisType.Self != this.axis.Type) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected)); } if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { long num = contextNode.CurrentPosition; opcode = next.Eval(destSequence, contextNode); contextNode.CurrentPosition = num; } return opcode; }
internal void Select(SeekableXPathNavigator contextNode, NodeSequence destSequence) { switch (this.type) { case QueryNodeType.Root: contextNode.MoveToRoot(); destSequence.Add(contextNode); return; case QueryNodeType.Attribute: if (contextNode.MoveToFirstAttribute()) { do { if (this.MatchQName(contextNode)) { destSequence.Add(contextNode); if (((byte) (this.qnameType & NodeQNameType.Wildcard)) == 0) { return; } } } while (contextNode.MoveToNextAttribute()); } return; case QueryNodeType.Element: if (QueryAxisType.Descendant != this.axis.Type) { if (QueryAxisType.DescendantOrSelf == this.axis.Type) { destSequence.Add(contextNode); this.SelectDescendants(contextNode, destSequence); return; } if (contextNode.MoveToFirstChild()) { do { if ((XPathNodeType.Element == contextNode.NodeType) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } } while (contextNode.MoveToNext()); } return; } this.SelectDescendants(contextNode, destSequence); return; case QueryNodeType.Text: if (contextNode.MoveToFirstChild()) { do { if (this.MatchType(contextNode)) { destSequence.Add(contextNode); } } while (contextNode.MoveToNext()); } return; case QueryNodeType.ChildNodes: if (QueryAxisType.Descendant == this.axis.Type) { this.SelectDescendants(contextNode, destSequence); return; } if (contextNode.MoveToFirstChild()) { do { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } } while (contextNode.MoveToNext()); } return; } if (QueryAxisType.Self == this.axis.Type) { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } } else if (QueryAxisType.Descendant == this.axis.Type) { this.SelectDescendants(contextNode, destSequence); } else if (QueryAxisType.DescendantOrSelf == this.axis.Type) { destSequence.Add(contextNode); this.SelectDescendants(contextNode, destSequence); } else if (QueryAxisType.Child == this.axis.Type) { if (contextNode.MoveToFirstChild()) { do { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } } while (contextNode.MoveToNext()); } } else { if (QueryAxisType.Attribute != this.axis.Type) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected)); } if (contextNode.MoveToFirstAttribute()) { do { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); if (((byte) (this.qnameType & NodeQNameType.Wildcard)) == 0) { return; } } } while (contextNode.MoveToNextAttribute()); } } }
internal void Select(SeekableXPathNavigator contextNode, NodeSequence destSequence) { switch (this.type) { case QueryNodeType.Root: contextNode.MoveToRoot(); destSequence.Add(contextNode); return; case QueryNodeType.Attribute: if (contextNode.MoveToFirstAttribute()) { do { if (this.MatchQName(contextNode)) { destSequence.Add(contextNode); if (((byte)(this.qnameType & NodeQNameType.Wildcard)) == 0) { return; } } }while (contextNode.MoveToNextAttribute()); } return; case QueryNodeType.Element: if (QueryAxisType.Descendant != this.axis.Type) { if (QueryAxisType.DescendantOrSelf == this.axis.Type) { destSequence.Add(contextNode); this.SelectDescendants(contextNode, destSequence); return; } if (contextNode.MoveToFirstChild()) { do { if ((XPathNodeType.Element == contextNode.NodeType) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } }while (contextNode.MoveToNext()); } return; } this.SelectDescendants(contextNode, destSequence); return; case QueryNodeType.Text: if (contextNode.MoveToFirstChild()) { do { if (this.MatchType(contextNode)) { destSequence.Add(contextNode); } }while (contextNode.MoveToNext()); } return; case QueryNodeType.ChildNodes: if (QueryAxisType.Descendant == this.axis.Type) { this.SelectDescendants(contextNode, destSequence); return; } if (contextNode.MoveToFirstChild()) { do { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } }while (contextNode.MoveToNext()); } return; } if (QueryAxisType.Self == this.axis.Type) { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } } else if (QueryAxisType.Descendant == this.axis.Type) { this.SelectDescendants(contextNode, destSequence); } else if (QueryAxisType.DescendantOrSelf == this.axis.Type) { destSequence.Add(contextNode); this.SelectDescendants(contextNode, destSequence); } else if (QueryAxisType.Child == this.axis.Type) { if (contextNode.MoveToFirstChild()) { do { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); } }while (contextNode.MoveToNext()); } } else { if (QueryAxisType.Attribute != this.axis.Type) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected)); } if (contextNode.MoveToFirstAttribute()) { do { if (this.MatchType(contextNode) && this.MatchQName(contextNode)) { destSequence.Add(contextNode); if (((byte)(this.qnameType & NodeQNameType.Wildcard)) == 0) { return; } } }while (contextNode.MoveToNextAttribute()); } } }