private void AnalyzePriority(Compiler compiler) {
NavigatorInput input = compiler.Input;
if (!Double.IsNaN(this.priority) || this.matchKey == Compiler.InvalidQueryKey) {
return;
}
// Split Unions:
TheQuery theQuery = (TheQuery)compiler.QueryStore[this.MatchKey];
CompiledXpathExpr expr = (CompiledXpathExpr)theQuery.CompiledQuery;
Query query = expr.QueryTree;
UnionExpr union;
while ((union = query as UnionExpr) != null) {
Debug.Assert(!(union.qy2 is UnionExpr), "only qy1 can be union");
TemplateAction copy = this.CloneWithoutName();
compiler.QueryStore.Add(new TheQuery(
new CompiledXpathExpr(union.qy2, expr.Expression, false),
theQuery._ScopeManager
));
copy.matchKey = compiler.QueryStore.Count - 1;
copy.priority = union.qy2.XsltDefaultPriority;
compiler.AddTemplate(copy);
query = union.qy1;
}
if (expr.QueryTree != query) {
// query was splitted and we need create new TheQuery for this template
compiler.QueryStore[this.MatchKey] = new TheQuery(
new CompiledXpathExpr(query, expr.Expression, false),
theQuery._ScopeManager
);
}
this.priority = query.XsltDefaultPriority;
}