Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ProcessFilter()

Query MS.Internal.Xml.XPath.QueryBuilder.ProcessFilter ( Filter root,
Flags flags,
out Props props )
inlineprivate

Definition at line 180 of file QueryBuilder.cs.

181 {
182 bool flag = (flags & Flags.Filter) == 0;
184 Query query = ProcessNode(root.Condition, Flags.None, out props2);
185 if (CanBeNumber(query) || (props2 & (Props)6) != 0)
186 {
187 props2 |= Props.HasPosition;
188 flags |= Flags.PosFilter;
189 }
190 flags &= (Flags)(-2);
191 Query query2 = ProcessNode(root.Input, flags | Flags.Filter, out props);
192 if (root.Input.Type != AstNode.AstType.Filter)
193 {
194 props &= (Props)(-2);
195 }
196 if ((props2 & Props.HasPosition) != 0)
197 {
198 props |= Props.PosFilter;
199 }
200 if (query2 is FilterQuery filterQuery && (props2 & Props.HasPosition) == 0 && filterQuery.Condition.StaticType != XPathResultType.Any)
201 {
202 Query query3 = filterQuery.Condition;
203 if (query3.StaticType == XPathResultType.Number)
204 {
205 query3 = new LogicalExpr(Operator.Op.EQ, new NodeFunctions(Function.FunctionType.FuncPosition, null), query3);
206 }
207 query = new BooleanExpr(Operator.Op.AND, query3, query);
208 query2 = filterQuery.qyInput;
209 }
210 if ((props & Props.PosFilter) != 0 && query2 is DocumentOrderQuery)
211 {
212 query2 = ((DocumentOrderQuery)query2).input;
213 }
214 if (_firstInput == null)
215 {
216 _firstInput = query2 as BaseAxisQuery;
217 }
218 bool flag2 = (query2.Properties & QueryProps.Merge) != 0;
219 bool flag3 = (query2.Properties & QueryProps.Reverse) != 0;
220 if ((props2 & Props.HasPosition) != 0)
221 {
222 if (flag3)
223 {
224 query2 = new ReversePositionQuery(query2);
225 }
226 else if ((props2 & Props.HasLast) != 0)
227 {
228 query2 = new ForwardPositionQuery(query2);
229 }
230 }
231 if (flag && _firstInput != null)
232 {
233 if (flag2 && (props & Props.PosFilter) != 0)
234 {
235 query2 = new FilterQuery(query2, query, noPosition: false);
236 Query qyInput = _firstInput.qyInput;
237 if (!(qyInput is ContextQuery))
238 {
239 _firstInput.qyInput = new ContextQuery();
240 _firstInput = null;
241 return new MergeFilterQuery(qyInput, query2);
242 }
243 _firstInput = null;
244 return query2;
245 }
246 _firstInput = null;
247 }
248 return new FilterQuery(query2, query, (props2 & Props.HasPosition) == 0);
249 }
Query ProcessNode(AstNode root, Flags flags, out Props props)

References MS.Internal.Xml.XPath.QueryBuilder._firstInput, MS.Internal.Xml.XPath.QueryBuilder.CanBeNumber(), MS.Internal.Xml.XPath.Filter.Condition, MS.Internal.Xml.XPath.Filter.Input, MS.Internal.Xml.XPath.QueryBuilder.ProcessNode(), MS.Internal.Xml.XPath.BaseAxisQuery.qyInput, and MS.Internal.Xml.XPath.AstNode.Type.

Referenced by MS.Internal.Xml.XPath.QueryBuilder.ProcessNode().