2007-02-06 Marek Safar <marek.safar@gmail.com>
[mono.git] / mcs / mcs / iterators.cs
index 753fda66c35bc5308e24664805ec7f08b6b8463a..c259e530e6aaf5f9d540b6d0f8d371e80fa9e8a2 100644 (file)
@@ -229,6 +229,27 @@ namespace Mono.CSharp {
                        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 ())
@@ -285,7 +306,7 @@ namespace Mono.CSharp {
                        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);
                }
 
@@ -792,7 +813,7 @@ namespace Mono.CSharp {
                //
                // 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,
                                new ToplevelBlock (m_container.ParameterInfo, m_container.Location),
@@ -894,6 +915,10 @@ namespace Mono.CSharp {
 
                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),
@@ -955,7 +980,7 @@ namespace Mono.CSharp {
                        }
                }
 
-               public static Iterator CreateIterator (IMethodData method, TypeContainer parent,
+               public static Iterator CreateIterator (IMethodData method, DeclSpace parent,
                                                       GenericMethod generic, int modifiers)
                {
                        bool is_enumerable;