Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XPathBuilder.cs
Go to the documentation of this file.
7
9
11{
12 private enum XPathOperatorGroup
13 {
14 Unknown,
15 Logical,
19 Negate,
20 Union
21 }
22
23 internal enum FuncId
24 {
25 Last,
27 Count,
30 Name,
31 String,
32 Number,
33 Boolean,
34 True,
35 False,
36 Not,
37 Id,
38 Concat,
47 Lang,
48 Sum,
49 Floor,
50 Ceiling,
51 Round
52 }
53
54 internal sealed class FixupVisitor : QilReplaceVisitor
55 {
56 private new readonly QilPatternFactory f;
57
58 private readonly QilNode _fixupCurrent;
59
60 private readonly QilNode _fixupPosition;
61
62 private readonly QilNode _fixupLast;
63
65
66 private QilNode _last;
67
68 private bool _justCount;
69
71
72 public int numCurrent;
73
74 public int numPosition;
75
76 public int numLast;
77
86
88 {
90 _current = current;
91 _last = last;
92 _justCount = false;
93 _environment = null;
94 numCurrent = (numPosition = (numLast = 0));
96 return inExpr;
97 }
98
109
111 {
112 _justCount = true;
113 numCurrent = (numPosition = (numLast = 0));
115 return numLast;
116 }
117
119 {
120 if (unknown == _fixupCurrent)
121 {
122 numCurrent++;
123 if (!_justCount)
124 {
125 if (_environment != null)
126 {
128 }
129 else if (_current != null)
130 {
132 }
133 }
134 }
135 else if (unknown == _fixupPosition)
136 {
137 numPosition++;
138 if (!_justCount)
139 {
140 if (_environment != null)
141 {
143 }
144 else if (_current != null)
145 {
146 unknown = f.XsltConvert(f.PositionOf(_current), XmlQueryTypeFactory.DoubleX);
147 }
148 }
149 }
150 else if (unknown == _fixupLast)
151 {
152 numLast++;
153 if (!_justCount)
154 {
155 if (_environment != null)
156 {
158 }
159 else if (_current != null)
160 {
161 unknown = _last;
162 }
163 }
164 }
165 return unknown;
166 }
167 }
168
169 internal sealed class FunctionInfo<T>
170 {
171 public T id;
172
173 public int minArgs;
174
175 public int maxArgs;
176
178
180 {
181 this.id = id;
185 }
186
187 public static void CheckArity(int minArgs, int maxArgs, string name, int numArgs)
188 {
189 if (minArgs <= numArgs && numArgs <= maxArgs)
190 {
191 return;
192 }
195 }
196
198 {
200 if (maxArgs == int.MaxValue)
201 {
202 for (int i = 0; i < args.Count; i++)
203 {
204 args[i] = f.ConvertToType(XmlTypeCode.String, args[i]);
205 }
206 return;
207 }
208 for (int j = 0; j < args.Count; j++)
209 {
210 if (argTypes[j] == XmlTypeCode.Node && f.CannotBeNodeSet(args[j]))
211 {
213 }
215 }
216 }
217 }
218
219 private readonly XPathQilFactory _f;
220
222
223 private bool _inTheBuild;
224
226
228
230
231 protected int numFixupCurrent;
232
233 protected int numFixupPosition;
234
235 protected int numFixupLast;
236
237 private readonly FixupVisitor _fixupVisitor;
238
240 {
241 XmlNodeKindFlags.Document,
242 XmlNodeKindFlags.Element,
243 XmlNodeKindFlags.Attribute,
244 XmlNodeKindFlags.Namespace,
245 XmlNodeKindFlags.Text,
246 XmlNodeKindFlags.Text,
247 XmlNodeKindFlags.Text,
249 XmlNodeKindFlags.Comment,
251 };
252
253 private static readonly XPathOperatorGroup[] s_operatorGroup = new XPathOperatorGroup[16]
254 {
255 XPathOperatorGroup.Unknown,
256 XPathOperatorGroup.Logical,
257 XPathOperatorGroup.Logical,
258 XPathOperatorGroup.Equality,
259 XPathOperatorGroup.Equality,
260 XPathOperatorGroup.Relational,
261 XPathOperatorGroup.Relational,
262 XPathOperatorGroup.Relational,
263 XPathOperatorGroup.Relational,
264 XPathOperatorGroup.Arithmetic,
265 XPathOperatorGroup.Arithmetic,
266 XPathOperatorGroup.Arithmetic,
267 XPathOperatorGroup.Arithmetic,
268 XPathOperatorGroup.Arithmetic,
269 XPathOperatorGroup.Negate,
271 };
272
273 private static readonly QilNodeType[] s_qilOperator = new QilNodeType[16]
274 {
275 QilNodeType.Unknown,
276 QilNodeType.Or,
277 QilNodeType.And,
278 QilNodeType.Eq,
279 QilNodeType.Ne,
280 QilNodeType.Lt,
281 QilNodeType.Le,
282 QilNodeType.Gt,
283 QilNodeType.Ge,
284 QilNodeType.Add,
285 QilNodeType.Subtract,
286 QilNodeType.Multiply,
287 QilNodeType.Divide,
288 QilNodeType.Modulo,
289 QilNodeType.Negate,
291 };
292
293 private static readonly XmlNodeKindFlags[] s_XPathAxisMask = new XmlNodeKindFlags[15]
294 {
295 XmlNodeKindFlags.None,
298 XmlNodeKindFlags.Attribute,
299 XmlNodeKindFlags.Content,
300 XmlNodeKindFlags.Content,
302 XmlNodeKindFlags.Content,
303 XmlNodeKindFlags.Content,
304 XmlNodeKindFlags.Namespace,
306 XmlNodeKindFlags.Content,
307 XmlNodeKindFlags.Content,
310 };
311
312 public static readonly XmlTypeCode[] argAny = new XmlTypeCode[1] { XmlTypeCode.Item };
313
314 public static readonly XmlTypeCode[] argNodeSet = new XmlTypeCode[1] { XmlTypeCode.Node };
315
316 public static readonly XmlTypeCode[] argBoolean = new XmlTypeCode[1] { XmlTypeCode.Boolean };
317
318 public static readonly XmlTypeCode[] argDouble = new XmlTypeCode[1] { XmlTypeCode.Double };
319
320 public static readonly XmlTypeCode[] argString = new XmlTypeCode[1] { XmlTypeCode.String };
321
322 public static readonly XmlTypeCode[] argString2 = new XmlTypeCode[2]
323 {
324 XmlTypeCode.String,
326 };
327
328 public static readonly XmlTypeCode[] argString3 = new XmlTypeCode[3]
329 {
330 XmlTypeCode.String,
331 XmlTypeCode.String,
333 };
334
335 public static readonly XmlTypeCode[] argFnSubstr = new XmlTypeCode[3]
336 {
337 XmlTypeCode.String,
338 XmlTypeCode.Double,
340 };
341
343
345
347 {
348 return GetCurrentNode();
349 }
350
352 {
353 return GetCurrentPosition();
354 }
355
357 {
358 return GetLastPosition();
359 }
360
362 {
363 return Variable(prefix, name);
364 }
365
367 {
368 return null;
369 }
370
375
385
386 public virtual void StartBuild()
387 {
388 _inTheBuild = true;
390 }
391
392 [return: NotNullIfNotNull("result")]
393 public virtual QilNode EndBuild(QilNode result)
394 {
395 if (result == null)
396 {
397 _inTheBuild = false;
398 return result;
399 }
400 if (result.XmlType.MaybeMany && result.XmlType.IsNode && result.XmlType.IsNotRtf)
401 {
402 result = _f.DocOrderDistinct(result);
403 }
404 result = _fixupVisitor.Fixup(result, _environment);
408 _inTheBuild = false;
409 return result;
410 }
411
413 {
415 return fixupCurrent;
416 }
417
419 {
421 return fixupPosition;
422 }
423
425 {
426 numFixupLast++;
427 return fixupLast;
428 }
429
430 public virtual QilNode String(string value)
431 {
432 return _f.String(value);
433 }
434
435 public virtual QilNode Number(double value)
436 {
437 return _f.Double(value);
438 }
439
440 public virtual QilNode Operator(XPathOperator op, QilNode left, QilNode right)
441 {
442 return s_operatorGroup[(int)op] switch
443 {
449 XPathOperatorGroup.Union => UnionOperator(op, left, right),
450 _ => null,
451 };
452 }
453
455 {
456 left = _f.ConvertToBoolean(left);
457 right = _f.ConvertToBoolean(right);
458 if (op != XPathOperator.Or)
459 {
460 return _f.And(left, right);
461 }
462 return _f.Or(left, right);
463 }
464
466 {
467 left = _f.ConvertToType(compType, left);
468 right = _f.ConvertToType(compType, right);
469 return op switch
470 {
471 XPathOperator.Eq => _f.Eq(left, right),
472 XPathOperator.Ne => _f.Ne(left, right),
473 XPathOperator.Lt => _f.Lt(left, right),
474 XPathOperator.Le => _f.Le(left, right),
475 XPathOperator.Gt => _f.Gt(left, right),
476 XPathOperator.Ge => _f.Ge(left, right),
477 _ => null,
478 };
479 }
480
490
492 {
493 return op switch
494 {
499 _ => op,
500 };
501 }
502
504 {
505 if (right.XmlType.IsSingleton)
506 {
507 return CompareNodeSetAndValue(op, left, right, compType);
508 }
509 if (left.XmlType.IsSingleton)
510 {
511 op = InvertOp(op);
512 return CompareNodeSetAndValue(op, right, left, compType);
513 }
517 }
518
520 {
521 XmlQueryType xmlType = left.XmlType;
523 if (_f.IsAnyType(left) || _f.IsAnyType(right))
524 {
525 return _f.InvokeEqualityOperator(s_qilOperator[(int)op], left, right);
526 }
527 if (xmlType.IsNode && xmlType2.IsNode)
528 {
529 return CompareNodeSetAndNodeSet(op, left, right, XmlTypeCode.String);
530 }
531 if (xmlType.IsNode)
532 {
533 return CompareNodeSetAndValue(op, left, right, xmlType2.TypeCode);
534 }
535 if (xmlType2.IsNode)
536 {
537 return CompareNodeSetAndValue(op, right, left, xmlType.TypeCode);
538 }
540 return CompareValues(op, left, right, compType);
541 }
542
544 {
545 XmlQueryType xmlType = left.XmlType;
547 if (_f.IsAnyType(left) || _f.IsAnyType(right))
548 {
549 return _f.InvokeRelationalOperator(s_qilOperator[(int)op], left, right);
550 }
551 if (xmlType.IsNode && xmlType2.IsNode)
552 {
553 return CompareNodeSetAndNodeSet(op, left, right, XmlTypeCode.Double);
554 }
555 if (xmlType.IsNode)
556 {
557 XmlTypeCode compType = ((xmlType2.TypeCode == XmlTypeCode.Boolean) ? XmlTypeCode.Boolean : XmlTypeCode.Double);
558 return CompareNodeSetAndValue(op, left, right, compType);
559 }
560 if (xmlType2.IsNode)
561 {
562 XmlTypeCode compType2 = ((xmlType.TypeCode == XmlTypeCode.Boolean) ? XmlTypeCode.Boolean : XmlTypeCode.Double);
563 op = InvertOp(op);
564 return CompareNodeSetAndValue(op, right, left, compType2);
565 }
566 return CompareValues(op, left, right, XmlTypeCode.Double);
567 }
568
570 {
571 return _f.Negate(_f.ConvertToNumber(left));
572 }
573
575 {
576 left = _f.ConvertToNumber(left);
577 right = _f.ConvertToNumber(right);
578 return op switch
579 {
580 XPathOperator.Plus => _f.Add(left, right),
581 XPathOperator.Minus => _f.Subtract(left, right),
582 XPathOperator.Multiply => _f.Multiply(left, right),
583 XPathOperator.Divide => _f.Divide(left, right),
584 XPathOperator.Modulo => _f.Modulo(left, right),
585 _ => null,
586 };
587 }
588
590 {
591 if (left == null)
592 {
593 return _f.EnsureNodeSet(right);
594 }
595 left = _f.EnsureNodeSet(left);
596 right = _f.EnsureNodeSet(right);
597 if (left.NodeType == QilNodeType.Sequence)
598 {
599 ((QilList)left).Add(right);
600 return left;
601 }
602 return _f.Union(left, right);
603 }
604
609
610 private QilNode BuildAxisFilter(QilNode qilAxis, XPathAxis xpathAxis, XPathNodeType nodeType, string name, string nsUri)
611 {
612 XmlNodeKindFlags nodeKinds = qilAxis.XmlType.NodeKinds;
615 {
616 return _f.Sequence();
617 }
618 QilIterator expr;
620 {
623 if (qilAxis.NodeType == QilNodeType.Filter)
624 {
626 qilLoop.Body = _f.And(qilLoop.Body, (name != null && nsUri != null) ? _f.Eq(_f.NameOf(expr), _f.QName(name, nsUri)) : ((nsUri != null) ? _f.Eq(_f.NamespaceUriOf(expr), _f.String(nsUri)) : ((name != null) ? _f.Eq(_f.LocalNameOf(expr), _f.String(name)) : _f.True())));
627 return qilLoop;
628 }
629 }
630 return _f.Filter(expr = _f.For(qilAxis), (name != null && nsUri != null) ? _f.Eq(_f.NameOf(expr), _f.QName(name, nsUri)) : ((nsUri != null) ? _f.Eq(_f.NamespaceUriOf(expr), _f.String(nsUri)) : ((name != null) ? _f.Eq(_f.LocalNameOf(expr), _f.String(name)) : _f.True())));
631 }
632
633 private QilNode BuildAxis(XPathAxis xpathAxis, XPathNodeType nodeType, string nsUri, string name)
634 {
635 QilNode currentNode = GetCurrentNode();
637 switch (xpathAxis)
638 {
639 case XPathAxis.Ancestor:
640 qilAxis = _f.Ancestor(currentNode);
641 break;
642 case XPathAxis.AncestorOrSelf:
643 qilAxis = _f.AncestorOrSelf(currentNode);
644 break;
645 case XPathAxis.Attribute:
646 qilAxis = _f.Content(currentNode);
647 break;
648 case XPathAxis.Child:
649 qilAxis = _f.Content(currentNode);
650 break;
651 case XPathAxis.Descendant:
652 qilAxis = _f.Descendant(currentNode);
653 break;
654 case XPathAxis.DescendantOrSelf:
655 qilAxis = _f.DescendantOrSelf(currentNode);
656 break;
657 case XPathAxis.Following:
658 qilAxis = _f.XPathFollowing(currentNode);
659 break;
660 case XPathAxis.FollowingSibling:
661 qilAxis = _f.FollowingSibling(currentNode);
662 break;
663 case XPathAxis.Namespace:
664 qilAxis = _f.XPathNamespace(currentNode);
665 break;
666 case XPathAxis.Parent:
667 qilAxis = _f.Parent(currentNode);
668 break;
669 case XPathAxis.Preceding:
670 qilAxis = _f.XPathPreceding(currentNode);
671 break;
672 case XPathAxis.PrecedingSibling:
673 qilAxis = _f.PrecedingSibling(currentNode);
674 break;
675 case XPathAxis.Self:
676 qilAxis = currentNode;
677 break;
678 case XPathAxis.Root:
679 return _f.Root(currentNode);
680 default:
681 qilAxis = null;
682 break;
683 }
684 QilNode qilNode = BuildAxisFilter(qilAxis, xpathAxis, nodeType, name, nsUri);
685 if (xpathAxis == XPathAxis.Ancestor || xpathAxis == XPathAxis.Preceding || xpathAxis == XPathAxis.AncestorOrSelf || xpathAxis == XPathAxis.PrecedingSibling)
686 {
688 }
689 return qilNode;
690 }
691
692 public virtual QilNode Axis(XPathAxis xpathAxis, XPathNodeType nodeType, string prefix, string name)
693 {
694 string nsUri = ((prefix == null) ? null : _environment.ResolvePrefix(prefix));
695 return BuildAxis(xpathAxis, nodeType, nsUri, name);
696 }
697
707
708 public virtual QilNode Predicate(QilNode nodeset, QilNode predicate, bool isReverseStep)
709 {
710 if (isReverseStep)
711 {
712 nodeset = ((QilUnary)nodeset).Child;
713 }
714 predicate = PredicateToBoolean(predicate, _f, this);
716 }
717
719 {
721 predicate = (f.IsAnyType(predicate) ? f.Loop(qilIterator = f.Let(predicate), f.Conditional(f.IsType(qilIterator, XmlQueryTypeFactory.Double), f.Eq(env.GetPosition(), f.TypeAssert(qilIterator, XmlQueryTypeFactory.DoubleX)), f.ConvertToBoolean(qilIterator))) : ((predicate.XmlType.TypeCode != XmlTypeCode.Double) ? f.ConvertToBoolean(predicate) : f.Eq(env.GetPosition(), predicate)));
722 return predicate;
723 }
724
726 {
729 if (numFixupLast != 0 && fixupVisitor.CountUnfixedLast(predicate) != 0)
730 {
734 predicate = fixupVisitor.Fixup(predicate, qilIterator3, qilIterator2);
735 numFixupCurrent -= fixupVisitor.numCurrent;
736 numFixupPosition -= fixupVisitor.numPosition;
737 numFixupLast -= fixupVisitor.numLast;
739 }
740 else
741 {
743 predicate = fixupVisitor.Fixup(predicate, qilIterator4, null);
744 numFixupCurrent -= fixupVisitor.numCurrent;
745 numFixupPosition -= fixupVisitor.numPosition;
746 numFixupLast -= fixupVisitor.numLast;
747 qilNode = f.Filter(qilIterator4, predicate);
748 }
749 if (isReverseStep)
750 {
752 }
753 return qilNode;
754 }
755
756 public virtual QilNode Variable(string prefix, string name)
757 {
758 return _environment.ResolveVariable(prefix, name);
759 }
760
761 public virtual QilNode Function(string prefix, string name, IList<QilNode> args)
762 {
763 if (prefix.Length == 0 && FunctionTable.TryGetValue(name, out var value))
764 {
765 value.CastArguments(args, name, _f);
766 switch (value.id)
767 {
768 case FuncId.Not:
769 return _f.Not(args[0]);
770 case FuncId.Last:
771 return GetLastPosition();
772 case FuncId.Position:
773 return GetCurrentPosition();
774 case FuncId.Count:
776 case FuncId.LocalName:
777 if (args.Count != 0)
778 {
779 return LocalNameOfFirstNode(args[0]);
780 }
781 return _f.LocalNameOf(GetCurrentNode());
782 case FuncId.NamespaceUri:
783 if (args.Count != 0)
784 {
785 return NamespaceOfFirstNode(args[0]);
786 }
788 case FuncId.Name:
789 if (args.Count != 0)
790 {
791 return NameOfFirstNode(args[0]);
792 }
793 return NameOf(GetCurrentNode());
794 case FuncId.String:
795 if (args.Count != 0)
796 {
797 return _f.ConvertToString(args[0]);
798 }
800 case FuncId.Number:
801 if (args.Count != 0)
802 {
803 return _f.ConvertToNumber(args[0]);
804 }
806 case FuncId.Boolean:
807 return _f.ConvertToBoolean(args[0]);
808 case FuncId.True:
809 return _f.True();
810 case FuncId.False:
811 return _f.False();
812 case FuncId.Id:
814 case FuncId.Concat:
815 return _f.StrConcat(args);
816 case FuncId.StartsWith:
817 return _f.InvokeStartsWith(args[0], args[1]);
818 case FuncId.Contains:
819 return _f.InvokeContains(args[0], args[1]);
820 case FuncId.SubstringBefore:
821 return _f.InvokeSubstringBefore(args[0], args[1]);
822 case FuncId.SubstringAfter:
823 return _f.InvokeSubstringAfter(args[0], args[1]);
824 case FuncId.Substring:
825 if (args.Count != 2)
826 {
827 return _f.InvokeSubstring(args[0], args[1], args[2]);
828 }
829 return _f.InvokeSubstring(args[0], args[1]);
830 case FuncId.StringLength:
832 case FuncId.Normalize:
834 case FuncId.Translate:
835 return _f.InvokeTranslate(args[0], args[1], args[2]);
836 case FuncId.Lang:
837 return _f.InvokeLang(args[0], GetCurrentNode());
838 case FuncId.Sum:
839 return Sum(_f.DocOrderDistinct(args[0]));
840 case FuncId.Floor:
841 return _f.InvokeFloor(args[0]);
842 case FuncId.Ceiling:
843 return _f.InvokeCeiling(args[0]);
844 case FuncId.Round:
845 return _f.InvokeRound(args[0]);
846 default:
847 return null;
848 }
849 }
850 return _environment.ResolveFunction(prefix, name, args, this);
851 }
852
854 {
855 if (arg.XmlType.IsSingleton)
856 {
857 return _f.LocalNameOf(arg);
858 }
859 QilIterator expr;
860 return _f.StrConcat(_f.Loop(expr = _f.FirstNode(arg), _f.LocalNameOf(expr)));
861 }
862
864 {
865 if (arg.XmlType.IsSingleton)
866 {
867 return _f.NamespaceUriOf(arg);
868 }
869 QilIterator expr;
870 return _f.StrConcat(_f.Loop(expr = _f.FirstNode(arg), _f.NamespaceUriOf(expr)));
871 }
872
884
886 {
887 if (arg.XmlType.IsSingleton)
888 {
889 return NameOf(arg);
890 }
893 }
894
896 {
898 return _f.Sum(_f.Sequence(_f.Double(0.0), _f.Loop(n = _f.For(arg), _f.ConvertToNumber(n))));
899 }
900
902 {
904 dictionary.Add("last", new FunctionInfo<FuncId>(FuncId.Last, 0, 0, null));
905 dictionary.Add("position", new FunctionInfo<FuncId>(FuncId.Position, 0, 0, null));
906 dictionary.Add("name", new FunctionInfo<FuncId>(FuncId.Name, 0, 1, argNodeSet));
907 dictionary.Add("namespace-uri", new FunctionInfo<FuncId>(FuncId.NamespaceUri, 0, 1, argNodeSet));
908 dictionary.Add("local-name", new FunctionInfo<FuncId>(FuncId.LocalName, 0, 1, argNodeSet));
909 dictionary.Add("count", new FunctionInfo<FuncId>(FuncId.Count, 1, 1, argNodeSet));
910 dictionary.Add("id", new FunctionInfo<FuncId>(FuncId.Id, 1, 1, argAny));
911 dictionary.Add("string", new FunctionInfo<FuncId>(FuncId.String, 0, 1, argAny));
912 dictionary.Add("concat", new FunctionInfo<FuncId>(FuncId.Concat, 2, int.MaxValue, null));
913 dictionary.Add("starts-with", new FunctionInfo<FuncId>(FuncId.StartsWith, 2, 2, argString2));
914 dictionary.Add("contains", new FunctionInfo<FuncId>(FuncId.Contains, 2, 2, argString2));
915 dictionary.Add("substring-before", new FunctionInfo<FuncId>(FuncId.SubstringBefore, 2, 2, argString2));
916 dictionary.Add("substring-after", new FunctionInfo<FuncId>(FuncId.SubstringAfter, 2, 2, argString2));
917 dictionary.Add("substring", new FunctionInfo<FuncId>(FuncId.Substring, 2, 3, argFnSubstr));
918 dictionary.Add("string-length", new FunctionInfo<FuncId>(FuncId.StringLength, 0, 1, argString));
919 dictionary.Add("normalize-space", new FunctionInfo<FuncId>(FuncId.Normalize, 0, 1, argString));
920 dictionary.Add("translate", new FunctionInfo<FuncId>(FuncId.Translate, 3, 3, argString3));
921 dictionary.Add("boolean", new FunctionInfo<FuncId>(FuncId.Boolean, 1, 1, argAny));
922 dictionary.Add("not", new FunctionInfo<FuncId>(FuncId.Not, 1, 1, argBoolean));
923 dictionary.Add("true", new FunctionInfo<FuncId>(FuncId.True, 0, 0, null));
924 dictionary.Add("false", new FunctionInfo<FuncId>(FuncId.False, 0, 0, null));
925 dictionary.Add("lang", new FunctionInfo<FuncId>(FuncId.Lang, 1, 1, argString));
926 dictionary.Add("number", new FunctionInfo<FuncId>(FuncId.Number, 0, 1, argAny));
927 dictionary.Add("sum", new FunctionInfo<FuncId>(FuncId.Sum, 1, 1, argNodeSet));
928 dictionary.Add("floor", new FunctionInfo<FuncId>(FuncId.Floor, 1, 1, argDouble));
929 dictionary.Add("ceiling", new FunctionInfo<FuncId>(FuncId.Ceiling, 1, 1, argDouble));
930 dictionary.Add("round", new FunctionInfo<FuncId>(FuncId.Round, 1, 1, argDouble));
931 return dictionary;
932 }
933
934 public static bool IsFunctionAvailable(string localName, string nsUri)
935 {
936 if (nsUri.Length != 0)
937 {
938 return false;
939 }
940 return FunctionTable.ContainsKey(localName);
941 }
942}
void Add(TKey key, TValue value)
static CultureInfo InvariantCulture
static string XPath_NodeSetArgumentExpected
Definition SR.cs:1854
static string XPath_AtMostMArgsExpected
Definition SR.cs:1852
static string XPath_AtLeastNArgsExpected
Definition SR.cs:1850
static string XPath_NOrMArgsExpected
Definition SR.cs:1848
static string XPath_NArgsExpected
Definition SR.cs:1846
Definition SR.cs:7
static void Check(QilNode input)
QilUnary DocOrderDistinct(QilNode child)
virtual bool Contains(QilNode node)
Definition QilNode.cs:142
virtual XmlQueryType XmlType
Definition QilNode.cs:29
virtual void Add(QilNode node)
Definition QilNode.cs:121
QilIterator For(QilNode binding)
QilNode Filter(QilIterator variable, QilNode expr)
QilNode IsType(QilNode expr, XmlQueryType t)
QilNode Union(QilNode left, QilNode right)
QilNode Modulo(QilNode left, QilNode right)
QilNode Multiply(QilNode left, QilNode right)
QilNode Loop(QilIterator variable, QilNode body)
QilNode Ge(QilNode left, QilNode right)
QilNode Conditional(QilNode condition, QilNode trueBranch, QilNode falseBranch)
QilIterator Let(QilNode binding)
QilNode XsltConvert(QilNode expr, XmlQueryType t)
QilNode Le(QilNode left, QilNode right)
QilNode Divide(QilNode left, QilNode right)
QilNode And(QilNode left, QilNode right)
QilNode Or(QilNode left, QilNode right)
QilNode Ne(QilNode left, QilNode right)
QilName QName(string local, string uri, string prefix)
QilNode DocOrderDistinct(QilNode collection)
QilNode Eq(QilNode left, QilNode right)
QilNode Gt(QilNode left, QilNode right)
QilNode Subtract(QilNode left, QilNode right)
QilNode Lt(QilNode left, QilNode right)
QilNode Add(QilNode left, QilNode right)
QilNode DescendantOrSelf(QilNode context)
QilNode TypeAssert(QilNode expr, XmlQueryType t)
virtual QilNode VisitAssumeReference(QilNode expr)
Definition QilVisitor.cs:5
FixupVisitor(QilPatternFactory f, QilNode fixupCurrent, QilNode fixupPosition, QilNode fixupLast)
override QilNode VisitUnknown(QilNode unknown)
QilNode Fixup(QilNode inExpr, IXPathEnvironment environment)
QilNode Fixup(QilNode inExpr, QilIterator current, QilNode last)
FunctionInfo(T id, int minArgs, int maxArgs, XmlTypeCode[] argTypes)
void CastArguments(IList< QilNode > args, string name, XPathQilFactory f)
static void CheckArity(int minArgs, int maxArgs, string name, int numArgs)
QilNode LogicalOperator(XPathOperator op, QilNode left, QilNode right)
virtual QilNode String(string value)
static readonly XPathOperatorGroup[] s_operatorGroup
QilNode LocalNameOfFirstNode(QilNode arg)
QilNode NameOfFirstNode(QilNode arg)
readonly FixupVisitor _fixupVisitor
readonly IXPathEnvironment _environment
QilNode CompareValues(XPathOperator op, QilNode left, QilNode right, XmlTypeCode compType)
QilNode CompareNodeSetAndNodeSet(XPathOperator op, QilNode left, QilNode right, XmlTypeCode compType)
XPathBuilder(IXPathEnvironment environment)
QilNode CompareNodeSetAndValue(XPathOperator op, QilNode nodeset, QilNode val, XmlTypeCode compType)
static readonly XmlNodeKindFlags[] s_XPathNodeType2QilXmlNodeKind
readonly XPathQilFactory _f
static readonly XmlNodeKindFlags[] s_XPathAxisMask
static readonly QilNodeType[] s_qilOperator
QilNode NegateOperator(XPathOperator op, QilNode left)
virtual QilNode Function(string prefix, string name, IList< QilNode > args)
QilNode ArithmeticOperator(XPathOperator op, QilNode left, QilNode right)
virtual QilNode JoinStep(QilNode left, QilNode right)
virtual QilNode EndBuild(QilNode result)
static readonly XmlTypeCode[] argString3
static readonly XmlTypeCode[] argFnSubstr
static Dictionary< string, FunctionInfo< FuncId > > FunctionTable
static readonly XmlTypeCode[] argBoolean
static bool IsFunctionAvailable(string localName, string nsUri)
static readonly XmlTypeCode[] argString
static readonly XmlTypeCode[] argAny
static readonly XmlTypeCode[] argString2
virtual QilNode Axis(XPathAxis xpathAxis, XPathNodeType nodeType, string prefix, string name)
static XmlNodeKindFlags AxisTypeMask(XmlNodeKindFlags inputTypeMask, XPathNodeType nodeType, XPathAxis xpathAxis)
static Dictionary< string, FunctionInfo< FuncId > > CreateFunctionTable()
virtual QilNode Operator(XPathOperator op, QilNode left, QilNode right)
static XPathOperator InvertOp(XPathOperator op)
QilNode UnionOperator(XPathOperator op, QilNode left, QilNode right)
virtual QilNode Variable(string prefix, string name)
QilNode NamespaceOfFirstNode(QilNode arg)
QilNode EqualityOperator(XPathOperator op, QilNode left, QilNode right)
virtual QilNode Number(double value)
static QilNode BuildOnePredicate(QilNode nodeset, QilNode predicate, bool isReverseStep, XPathQilFactory f, FixupVisitor fixupVisitor, ref int numFixupCurrent, ref int numFixupPosition, ref int numFixupLast)
static readonly XmlTypeCode[] argNodeSet
QilNode BuildAxis(XPathAxis xpathAxis, XPathNodeType nodeType, string nsUri, string name)
QilNode RelationalOperator(XPathOperator op, QilNode left, QilNode right)
QilNode BuildAxisFilter(QilNode qilAxis, XPathAxis xpathAxis, XPathNodeType nodeType, string name, string nsUri)
static readonly XmlTypeCode[] argDouble
virtual QilNode Predicate(QilNode nodeset, QilNode predicate, bool isReverseStep)
static QilNode PredicateToBoolean(QilNode predicate, XPathQilFactory f, IXPathEnvironment env)
QilNode InvokeStartsWith(QilNode str1, QilNode str2)
QilNode InvokeSubstring(QilNode str, QilNode start)
QilNode InvokeLang(QilNode lang, QilNode context)
QilNode InvokeSubstringBefore(QilNode str1, QilNode str2)
QilNode InvokeSubstringAfter(QilNode str1, QilNode str2)
QilNode InvokeRelationalOperator(QilNodeType op, QilNode left, QilNode right)
QilNode InvokeEqualityOperator(QilNodeType op, QilNode left, QilNode right)
QilNode Id(QilNode context, QilNode id)
QilNode InvokeContains(QilNode str1, QilNode str2)
QilNode InvokeTranslate(QilNode str1, QilNode str2, QilNode str3)
QilNode ConvertToType(XmlTypeCode requiredType, QilNode n)
static readonly XmlQueryType DoubleX
static readonly XmlQueryType Double
static XmlQueryType PrimeProduct(XmlQueryType t, XmlQueryCardinality c)
static XmlQueryType NodeChoice(XmlNodeKindFlags kinds)
static readonly XmlQueryType NodeNotRtf
QilNode ResolveFunction(string prefix, string name, IList< QilNode > args, IFocus env)
QilNode ResolveVariable(string prefix, string name)
string ResolvePrefix(string prefix)