Author: martin
Date: 2007-03-29 05:57:57 -0500 (Thu, 29 Mar 2007)
New Revision: 75127

Added:
   trunk/mcs/tests/gtest-324.cs
Modified:
   trunk/mcs/mcs/ChangeLog
   trunk/mcs/mcs/anonymous.cs
   trunk/mcs/mcs/statement.cs
Log:
2007-03-29  Martin Baulig  <[EMAIL PROTECTED]>

        Fix #79148.

        * anonymous.cs
        (ScopeInfo.ctor): Use `Modifiers.PUBLIC' if we're a nested
        CompilerGeneratedClass.
        (ScopeInfo.EmitScopeInstance): Make this protected.
        (CapturedVariable.EmitInstance): Use `Ldarg_0' if
        `ec.CurrentAnonymousMethod.Scope == Scope'.

        * statement.cs (Block.ScopeInfo): Make this a property.



Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2007-03-29 09:29:32 UTC (rev 75126)
+++ trunk/mcs/mcs/ChangeLog     2007-03-29 10:57:57 UTC (rev 75127)
@@ -1,3 +1,16 @@
+2007-03-29  Martin Baulig  <[EMAIL PROTECTED]>
+
+       Fix #79148.
+
+       * anonymous.cs
+       (ScopeInfo.ctor): Use `Modifiers.PUBLIC' if we're a nested
+       CompilerGeneratedClass.
+       (ScopeInfo.EmitScopeInstance): Make this protected.
+       (CapturedVariable.EmitInstance): Use `Ldarg_0' if
+       `ec.CurrentAnonymousMethod.Scope == Scope'.
+
+       * statement.cs (Block.ScopeInfo): Make this a property.
+
 2007-03-27  Raja R Harinath  <[EMAIL PROTECTED]>
 
        Prepare to kill 'Reachability'

Modified: trunk/mcs/mcs/anonymous.cs
===================================================================
--- trunk/mcs/mcs/anonymous.cs  2007-03-29 09:29:32 UTC (rev 75126)
+++ trunk/mcs/mcs/anonymous.cs  2007-03-29 10:57:57 UTC (rev 75127)
@@ -222,8 +222,13 @@
                        return new_scope;
                }
 
+               private static int default_modflags (DeclSpace parent)
+               {
+                       return parent is CompilerGeneratedClass ? 
Modifiers.PUBLIC : Modifiers.PRIVATE;
+               }
+
                protected ScopeInfo (Block block, DeclSpace parent, 
GenericMethod generic)
-                       : base (parent, generic, 0, block.StartLocation)
+                       : base (parent, generic, default_modflags (parent), 
block.StartLocation)
                {
                        Parent = parent;
                        RootScope = block.Toplevel.RootScope;
@@ -237,7 +242,7 @@
 
                protected ScopeInfo (ToplevelBlock toplevel, DeclSpace parent,
                                     GenericMethod generic, Location loc)
-                       : base (parent, generic, 0, loc)
+                       : base (parent, generic, default_modflags (parent), loc)
                {
                        Parent = parent;
                        RootScope = (RootScopeInfo) this;
@@ -265,7 +270,7 @@
                        return (CapturedVariable) captured_scopes [scope];
                }
 
-               public void EmitScopeInstance (EmitContext ec)
+               protected void EmitScopeInstance (EmitContext ec)
                {
                        if (scope_initializer == null) {
                                //
@@ -465,6 +470,12 @@
 
                        public override void EmitInstance (EmitContext ec)
                        {
+                               if ((ec.CurrentAnonymousMethod != null) &&
+                                   (ec.CurrentAnonymousMethod.Scope == Scope)) 
{
+                                       ec.ig.Emit (OpCodes.Ldarg_0);
+                                       return;
+                               }
+
                                Scope.EmitScopeInstance (ec);
                        }
 

Modified: trunk/mcs/mcs/statement.cs
===================================================================
--- trunk/mcs/mcs/statement.cs  2007-03-29 09:29:32 UTC (rev 75126)
+++ trunk/mcs/mcs/statement.cs  2007-03-29 10:57:57 UTC (rev 75127)
@@ -2013,14 +2013,18 @@
                        }
                }
 
-               public ScopeInfo ScopeInfo;
+               protected ScopeInfo scope_info;
 
+               public ScopeInfo ScopeInfo {
+                       get { return scope_info; }
+               }
+
                public ScopeInfo CreateScopeInfo ()
                {
-                       if (ScopeInfo == null)
-                               ScopeInfo = ScopeInfo.CreateScope (this);
+                       if (scope_info == null)
+                               scope_info = ScopeInfo.CreateScope (this);
 
-                       return ScopeInfo;
+                       return scope_info;
                }
 
                public ArrayList AnonymousChildren {
@@ -2620,7 +2624,10 @@
                                root_scope = new RootScopeInfo (
                                        this, host, generic, StartLocation);
 
-                       ScopeInfo = root_scope;
+                       if (scope_info != null)
+                               throw new InternalErrorException ();
+
+                       scope_info = root_scope;
                        return root_scope;
                }
 
@@ -2632,7 +2639,7 @@
                        if ((container != null) || (root_scope != null))
                                throw new InternalErrorException ();
 
-                       ScopeInfo = root_scope = root;
+                       scope_info = root_scope = root;
                }
 
                public RootScopeInfo RootScope {

Added: trunk/mcs/tests/gtest-324.cs
===================================================================
--- trunk/mcs/tests/gtest-324.cs        2007-03-29 09:29:32 UTC (rev 75126)
+++ trunk/mcs/tests/gtest-324.cs        2007-03-29 10:57:57 UTC (rev 75127)
@@ -0,0 +1,30 @@
+public delegate void A();
+
+class B
+{
+       public static event A D;
+       long[] d = new long [1];
+
+       void C ()
+       {
+               int a = 0;
+               int b = 0;
+
+               A block = delegate {
+                       long c = 0;
+
+                       B.D += delegate {
+                               d [b] = c;
+                               F (c);
+                       };
+               };
+       }
+
+       public void F (long i)
+       {
+       }
+
+       static void Main ()
+       {
+       }
+}


Property changes on: trunk/mcs/tests/gtest-324.cs
___________________________________________________________________
Name: svn:executable
   + *

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to