{
ec.CurrentIterator.MarkYield (ec, expr, finally_blocks);
}
+
+ protected override void CloneTo (CloneContext clonectx, Statement t)
+ {
+ Yield target = (Yield) t;
+
+ target.expr = expr.Clone (clonectx);
+ }
}
public class YieldBreak : Statement {
TypeExpr enumerable_type;
TypeArguments generic_args;
TypeExpr generic_enumerator_type;
+#if GMCS_SOURCE
TypeExpr generic_enumerable_type;
-
+#endif
+
public IteratorHost (Iterator iterator)
: base (iterator.Container.Toplevel, iterator.Host, iterator.GenericMethod,
iterator.Location)
return base.DoResolveMembers ();
}
+ public void CaptureScopes ()
+ {
+ Report.Debug (128, "DEFINE ITERATOR HOST", this, scopes);
+
+ foreach (ScopeInfo si in scopes)
+ CaptureScope (si);
+
+ foreach (ScopeInfo si in scopes) {
+ if (!si.Define ())
+ throw new InternalErrorException ();
+ if (si.DefineType () == null)
+ throw new InternalErrorException ();
+ if (!si.ResolveType ())
+ throw new InternalErrorException ();
+ if (!si.ResolveMembers ())
+ throw new InternalErrorException ();
+ if (!si.DefineMembers ())
+ throw new InternalErrorException ();
+ }
+ }
+
protected override bool DoDefineMembers ()
{
if (!base.DoDefineMembers ())
Accessor getter = new Accessor (get_block, 0, null, Location);
Property current = new Property (
- this, type, 0, false, name, null, getter, null);
+ this, type, 0, false, name, null, getter, null, false);
AddProperty (current);
}
ce = TypeManager.int_interlocked_compare_exchange;
- ec.CurrentBranching.CurrentUsageVector.Return ();
+ ec.CurrentBranching.CurrentUsageVector.Goto ();
return true;
}
public override bool Resolve (EmitContext ec)
{
- ec.CurrentBranching.CurrentUsageVector.Return ();
+ ec.CurrentBranching.CurrentUsageVector.Goto ();
return true;
}
point.Define (ig);
}
+ public override string ContainerType {
+ get { return "iterator"; }
+ }
+
public override bool IsIterator {
get { return true; }
}
get { return IteratorHost; }
}
+ public override ScopeInfo Scope {
+ get { return IteratorHost; }
+ }
+
//
// Our constructor
//
- public Iterator (IMethodData m_container, TypeContainer host, GenericMethod generic,
+ private Iterator (IMethodData m_container, DeclSpace host, GenericMethod generic,
int modifiers, Type iterator_type, bool is_enumerable)
- : base (null, host, generic, m_container.ParameterInfo,
+ : base (host, generic, m_container.ParameterInfo,
new ToplevelBlock (m_container.ParameterInfo, m_container.Location),
m_container.Block, TypeManager.bool_type, modifiers,
m_container.Location)
return OriginalMethod.GetSignatureForError ();
}
- public override bool Resolve (EmitContext ec)
+ public override bool Define (EmitContext ec)
{
Report.Debug (64, "RESOLVE ITERATOR", this, Container, Block);
return false;
}
- if (!base.Resolve (ec))
+ if (!base.Define (ec))
return false;
Report.Debug (64, "RESOLVE ITERATOR #1", this, method, method.Parent,
protected override Method DoCreateMethodHost (EmitContext ec)
{
+ Report.Debug (128, "CREATE METHOD HOST", this, IteratorHost);
+
+ IteratorHost.CaptureScopes ();
+
return new AnonymousMethodMethod (
this, RootScope, null, TypeManager.system_boolean_expr,
Modifiers.PUBLIC, new MemberName ("MoveNext", Location),
Parameters.EmptyReadOnlyParameters);
}
+ public override Expression Resolve (EmitContext ec)
+ {
+ throw new NotSupportedException ();
+ }
+
protected class MoveNextStatement : Statement {
Iterator iterator;
if (Expr == null)
return false;
- ec.CurrentBranching.CurrentUsageVector.Return ();
+ ec.CurrentBranching.CurrentUsageVector.Goto ();
return true;
}
}
}
- public static Iterator CreateIterator (IMethodData method, TypeContainer parent,
+ public static Iterator CreateIterator (IMethodData method, DeclSpace parent,
GenericMethod generic, int modifiers)
{
bool is_enumerable;
Type iterator_type;
- if (!CheckType (method.ReturnType, out iterator_type, out is_enumerable)) {
+ Type ret = method.ReturnType;
+ if (ret == null)
+ return null;
+
+ if (!CheckType (ret, out iterator_type, out is_enumerable)) {
Report.Error (1624, method.Location,
"The body of `{0}' cannot be an iterator block " +
"because `{1}' is not an iterator interface type",
method.GetSignatureForError (),
- TypeManager.CSharpName (method.ReturnType));
+ TypeManager.CSharpName (ret));
return null;
}