//
// Called back from YieldStatement
//
public virtual void InjectYield(EmitContext ec, Expression expr, int resume_pc, bool unwind_protect, Label resume_point)
{
//
// Guard against being disposed meantime
//
Label disposed = ec.DefineLabel();
var iterator = storey as IteratorStorey;
if (iterator != null)
{
ec.EmitThis();
ec.Emit(OpCodes.Ldfld, iterator.DisposingField.Spec);
ec.Emit(OpCodes.Brtrue_S, disposed);
}
//
// store resume program-counter
//
ec.EmitThis();
ec.EmitInt(resume_pc);
ec.Emit(OpCodes.Stfld, storey.PC.Spec);
if (iterator != null)
{
ec.MarkLabel(disposed);
}
// mark finally blocks as disabled
if (unwind_protect && skip_finally != null)
{
ec.EmitInt(1);
ec.Emit(OpCodes.Stloc, skip_finally);
}
}