protected override QilNode VisitXsltGenerateId(QilUnary ndGenId) {
Label lblOnEnd, lblDone;
this.helper.LoadQueryRuntime();
// If the expression is a singleton,
if (ndGenId.Child.XmlType.IsSingleton) {
// Then generate code to push expresion result onto the stack
NestedVisitEnsureStack(ndGenId.Child, typeof(XPathNavigator), false);
// runtime.GenerateId(value);
this.helper.Call(XmlILMethods.GenId);
}
else {
lblOnEnd = this.helper.DefineLabel();
// Construct nested iterator and iterate over results
StartNestedIterator(ndGenId.Child, lblOnEnd);
Visit(ndGenId.Child);
this.iterCurr.EnsureStackNoCache();
this.iterCurr.EnsureItemStorageType(ndGenId.Child.XmlType, typeof(XPathNavigator));
// runtime.GenerateId(value);
this.helper.Call(XmlILMethods.GenId);
// Handle empty sequence by pushing empty string onto the stack
lblDone = this.helper.DefineLabel();
this.helper.EmitUnconditionalBranch(OpCodes.Br, lblDone);
this.helper.MarkLabel(lblOnEnd);
this.helper.Emit(OpCodes.Pop);
this.helper.Emit(OpCodes.Ldstr, "");
this.helper.MarkLabel(lblDone);
// End nested iterator
EndNestedIterator(ndGenId.Child);
}
this.iterCurr.Storage = StorageDescriptor.Stack(typeof(string), false);
return ndGenId;
}