public QilLoop ConstructLoop(QilNode body) {
QilLoop result;
if (last != null) {
// last() encountered either in the sort keys or in the body of the current loop
EnsureCache();
last.Binding = f.XsltConvert(f.Length(cached), T.DoubleX);
}
result = f.BaseFactory.Loop(current, body);
if (last != null) {
result = f.BaseFactory.Loop(last, result);
}
if (cached != null) {
result = f.BaseFactory.Loop(cached, result);
}
return result;
}
}