protected override QilNode VisitTypeAssert(QilTargetType ndTypeAssert) {
if (!ndTypeAssert.Source.XmlType.IsSingleton && !this.iterCurr.HasLabelNext) {
// This case occurs when a non-singleton expression is treated as cardinality One.
// The trouble is that the expression will branch to an end label when it's done iterating, so
// an end label must be provided. But there is no next label in the current iteration context,
// so we've got to create a dummy label instead (IL requires it). This creates an infinite loop,
// but since it's known statically that the expression is cardinality One, this branch will never
// be taken.
Label lblDummy = this.helper.DefineLabel();
this.helper.MarkLabel(lblDummy);
NestedVisit(ndTypeAssert.Source, lblDummy);
}
else {
// Generate code for child expression
Visit(ndTypeAssert.Source);
}
this.iterCurr.EnsureItemStorageType(ndTypeAssert.Source.XmlType, GetItemStorageType(ndTypeAssert));
return ndTypeAssert;
}