2005-02-11 Miguel de Icaza <miguel@novell.com>
authorMiguel de Icaza <miguel@gnome.org>
Sat, 12 Feb 2005 05:14:08 +0000 (05:14 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Sat, 12 Feb 2005 05:14:08 +0000 (05:14 -0000)
* codegen.cs (EmitContext): Introduce the `MethodIsStatic'
variable.  This one is represents the actual low-level declaration
of the method, as opposed to the semantic level `IsStatic'.

An anonymous method which is hosted into a static method might be
actually an instance method.  IsStatic would reflect the
container, while MethodIsStatic represents the actual code
generated.

* expression.cs (ParameterReference): Use the new MethodIsStatic
instead of IsStatic.

svn path=/trunk/mcs/; revision=40523

mcs/mcs/ChangeLog
mcs/mcs/anonymous.cs
mcs/mcs/codegen.cs
mcs/mcs/expression.cs

index b47880f607be1192cacd4b4dc5989d0577e4c202..774ddaffcc1449f541e39c585265d3853fbc5bc0 100644 (file)
@@ -1,5 +1,17 @@
 2005-02-11  Miguel de Icaza  <miguel@novell.com>
 
+       * codegen.cs (EmitContext): Introduce the `MethodIsStatic'
+       variable.  This one is represents the actual low-level declaration
+       of the method, as opposed to the semantic level `IsStatic'.   
+
+       An anonymous method which is hosted into a static method might be
+       actually an instance method.  IsStatic would reflect the
+       container, while MethodIsStatic represents the actual code
+       generated.
+
+       * expression.cs (ParameterReference): Use the new MethodIsStatic
+       instead of IsStatic.
+
        * anonymous.cs (AnonymousMethod.Compatible): Pass the
        Modifiers.STATIC to the Anonymous' Method EmitContext if static is
        set on the current EmitContext. 
index 0ebc9091ef1dc03ce9a608a9d075b7b40a7ad9e7..8504e0dbc956bc9f5652d72c8f677c2f90ca4fe4 100644 (file)
@@ -123,8 +123,9 @@ namespace Mono.CSharp {
                                throw new Exception ("Type host is null");
                        
                        if (current_type == type_host && ec.IsStatic){
-                               if (ec.IsStatic)
+                               if (ec.IsStatic){
                                        method_modifiers |= Modifiers.STATIC;
+                               }
                                current_type = null;
                        } 
 
@@ -134,7 +135,6 @@ namespace Mono.CSharp {
                                method_modifiers, false, new MemberName ("<#AnonymousMethod>" + anonymous_method_count++),
                                Parameters, null, loc);
                        method.Block = Block;
-
                        
                        //
                        // Swap the TypeBuilder while we define the method, then restore
@@ -309,8 +309,7 @@ namespace Mono.CSharp {
                        // Adjust based on the computed state of the
                        // method from CreateMethodHost
                        
-                       if ((method_modifiers & Modifiers.STATIC) != 0)
-                               aec.IsStatic = true;
+                       aec.MethodIsStatic = (method_modifiers & Modifiers.STATIC) != 0;
                        
                        aec.EmitMeta (Block, amp);
                        aec.EmitResolvedTopBlock (Block, unreachable);
index fdf3917105cd479384527521522dbb10510aee20..c2131f29c5497163bcbf4c57a31a5a8d075a0c85 100644 (file)
@@ -291,6 +291,16 @@ namespace Mono.CSharp {
                /// </summary>
                public bool IsStatic;
 
+               /// <summary>
+               ///   Whether the actual created method is static or instance method.
+               ///   Althoug the method might be declared as `static', if an anonymous
+               ///   method is involved, we might turn this into an instance method.
+               ///
+               ///   So this reflects the low-level staticness of the method, while
+               ///   IsStatic represents the semantic, high-level staticness.
+               /// </summary>
+               public bool MethodIsStatic;
+
                /// <summary>
                ///   Whether we are emitting a field initializer
                /// </summary>
@@ -423,9 +433,8 @@ namespace Mono.CSharp {
                }
                
                Phase current_phase;
-               
                FlowBranching current_flow_branching;
-
+               
                public EmitContext (DeclSpace parent, DeclSpace ds, Location l, ILGenerator ig,
                                    Type return_type, int code_flags, bool is_constructor)
                {
@@ -437,6 +446,7 @@ namespace Mono.CSharp {
                        ConstantCheckState = true;
 
                        IsStatic = (code_flags & Modifiers.STATIC) != 0;
+                       MethodIsStatic = IsStatic;
                        InIterator = (code_flags & Modifiers.METHOD_YIELDS) != 0;
                        RemapToProxy = InIterator;
                        ReturnType = return_type;
index 1dce2663feee084a0e689d9e56ea0cf7ff1fce87..f2a3c31f82d92a9b343750b64685b55ebcf759a2 100644 (file)
@@ -3978,8 +3978,10 @@ namespace Mono.CSharp {
                        ILGenerator ig = ec.ig;
                        int arg_idx = idx;
 
-                       if (!ec.IsStatic)
+                       Console.WriteLine ("Loading: " + ec.MethodIsStatic);
+                       if (!ec.MethodIsStatic)
                                arg_idx++;
+                       
 
                        EmitLdArg (ig, arg_idx);
 
@@ -4003,7 +4005,8 @@ namespace Mono.CSharp {
                        ILGenerator ig = ec.ig;
                        int arg_idx = idx;
 
-                       if (!ec.IsStatic)
+                       Console.WriteLine ("Loading: {0} at {1}", ec.MethodIsStatic, ec.id);
+                       if (!ec.MethodIsStatic)
                                arg_idx++;
 
                        EmitLdArg (ig, arg_idx);
@@ -4041,7 +4044,7 @@ namespace Mono.CSharp {
                        
                        prepared = prepare_for_load;
                        
-                       if (!ec.IsStatic)
+                       if (!ec.MethodIsStatic)
                                arg_idx++;
 
                        if (is_ref && !prepared)
@@ -4079,7 +4082,7 @@ namespace Mono.CSharp {
                        
                        int arg_idx = idx;
 
-                       if (!ec.IsStatic)
+                       if (!ec.MethodIsStatic)
                                arg_idx++;
 
                        if (is_ref){