public override void VisitTypecase(TypecaseStatement typecase)
{
Label endLabel = ilGenerator.DefineLabel();
foreach (TypecaseWhen when in typecase.WhenPartList) {
Label nextLabel = ilGenerator.DefineLabel();
typecase.Variable.Accept(this);
ilGenerator.Emit(OpCodes.Isinst, when.TypeSpecifier.RawType);
ilGenerator.Emit(OpCodes.Brfalse, nextLabel);
when.LocalVariable.Declare(ilGenerator);
when.LocalVariable.EmitStorePrefix(ilGenerator);
typecase.Variable.Accept(this);
TypeData varType = typecase.Variable.NodeType;
TypeData whenType = when.TypeSpecifier.NodeType;
if (!varType.IsSubtypeOf(whenType)) {
UnboxIfNecessary(varType.RawType, whenType.RawType);
}
when.LocalVariable.EmitStore(ilGenerator);
when.ThenPart.Accept(this);
ilGenerator.Emit(OpCodes.Br, endLabel);
ilGenerator.MarkLabel(nextLabel);
}
if (typecase.ElsePart != null)
typecase.ElsePart.Accept(this);
ilGenerator.MarkLabel(endLabel);
}