public static QilNode GetCurrentPosition(QilFactory f, QilTuple context) {
Debug.Assert(context != null);
if (context.Where.Type != QilNodeType.True) {
Debug.Assert(context.For.Type == QilNodeType.For);
// convert context (1) --> (2)
QilIterator for2 = f.For(context.For.Binding);
QilNode cnd2 = new Replacer(f).Replace(/*inExpr:*/context.Where, /*from:*/context.For, /*to:*/for2);
context.For.Binding = f.OldTuple(for2, cnd2, for2);
context.Where = f.True();
}
return f.Convert(f.PositionOf((QilIterator)XPathContext.GetCurrentNode(context)), f.TypeFactory.Double());
}