- public override bool Resolve (EmitContext ec)
- {
- if (!Yield.CheckContext (ec, loc, true))
- return false;
-
- ec.CurrentBranching.CurrentUsageVector.Goto ();
- return true;
- }
-
- protected override void DoEmit (EmitContext ec)
- {
- ec.CurrentIterator.EmitYieldBreak (ec.ig);
- }
- }
-
- public class IteratorHost : RootScopeInfo
- {
- public readonly Iterator Iterator;
-
- TypeExpr iterator_type_expr;
- Field pc_field;
- Field current_field;
- MethodInfo dispose_method;
-
- TypeExpr enumerator_type;
- TypeExpr enumerable_type;
- TypeArguments generic_args;
- TypeExpr generic_enumerator_type;
- TypeExpr generic_enumerable_type;
-
- public IteratorHost (Iterator iterator)
- : base (iterator.Container.Toplevel, iterator.Host, iterator.GenericMethod,
- iterator.Location)
- {
- this.Iterator = iterator;
- }
-
- public override bool IsIterator {
- get { return true; }
- }
-
- public MethodInfo Dispose {
- get { return dispose_method; }
- }
-
- public Field PC {
- get { return pc_field; }
- }
-
- public Field CurrentField {
- get { return current_field; }
- }
-
- public Type IteratorType {
- get { return iterator_type_expr.Type; }
- }
-
- public override TypeExpr [] GetClassBases (out TypeExpr base_class)
- {
- iterator_type_expr = InflateType (Iterator.OriginalIteratorType);
-
-#if GMCS_SOURCE
- generic_args = new TypeArguments (Location);
- generic_args.Add (iterator_type_expr);
-#endif
-
- ArrayList list = new ArrayList ();
- if (Iterator.IsEnumerable) {
- enumerable_type = new TypeExpression (
- TypeManager.ienumerable_type, Location);
- list.Add (enumerable_type);
-
-#if GMCS_SOURCE
- generic_enumerable_type = new ConstructedType (
- TypeManager.generic_ienumerable_type,
- generic_args, Location);
- list.Add (generic_enumerable_type);
-#endif
- }
-
- enumerator_type = new TypeExpression (
- TypeManager.ienumerator_type, Location);
- list.Add (enumerator_type);
-
- list.Add (new TypeExpression (TypeManager.idisposable_type, Location));
-
-#if GMCS_SOURCE
- generic_enumerator_type = new ConstructedType (
- TypeManager.generic_ienumerator_type,
- generic_args, Location);
- list.Add (generic_enumerator_type);
-#endif
-
- Bases = list;
-
- return base.GetClassBases (out base_class);
- }
-
- protected override bool DoResolveMembers ()