Author: martin
Date: 2005-07-08 08:57:57 -0400 (Fri, 08 Jul 2005)
New Revision: 47094

Modified:
   trunk/mcs/gmcs/ChangeLog
   trunk/mcs/gmcs/ecore.cs
   trunk/mcs/gmcs/expression.cs
Log:
**** Merged r46761 from MCS ****


Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog    2005-07-08 12:57:29 UTC (rev 47093)
+++ trunk/mcs/gmcs/ChangeLog    2005-07-08 12:57:57 UTC (rev 47094)
@@ -1,3 +1,13 @@
+2005-06-30  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       Fix #75283.
+       * ecore.cs (MemberExpr.EmitInstance): New.  Add CS0120 check.
+       Refactored from ...
+       (FieldExpr.EmitInstance, PropertyExpr.EmitInstance): ... these.
+       (FieldExpr.Emit, PropertyExpr.Emit): Update.
+       (FieldExpr.EmitAssign, PropertyExpr.EmitAssign): Update.
+       * expression.cs (Invocation.EmitCall): Add CS0120 check.
+
 2005-06-30  Marek Safar  <[EMAIL PROTECTED]>
 
        Fix #75322

Modified: trunk/mcs/gmcs/ecore.cs
===================================================================
--- trunk/mcs/gmcs/ecore.cs     2005-07-08 12:57:29 UTC (rev 47093)
+++ trunk/mcs/gmcs/ecore.cs     2005-07-08 12:57:57 UTC (rev 47094)
@@ -2782,6 +2782,32 @@
 
                        return this;
                }
+
+               protected void EmitInstance (EmitContext ec, bool 
prepare_for_load)
+               {
+                       if (IsStatic)
+                               return;
+
+                       if (InstanceExpression == EmptyExpression.Null) {
+                               SimpleName.Error_ObjectRefRequired (ec, loc, 
Name);
+                               return;
+                       }
+                               
+                       if (InstanceExpression.Type.IsValueType) {
+                               if (InstanceExpression is IMemoryLocation) {
+                                       ((IMemoryLocation) 
InstanceExpression).AddressOf (ec, AddressOp.LoadStore);
+                               } else {
+                                       LocalTemporary t = new LocalTemporary 
(ec, InstanceExpression.Type);
+                                       InstanceExpression.Emit (ec);
+                                       t.Store (ec);
+                                       t.AddressOf (ec, AddressOp.Store);
+                               }
+                       } else
+                               InstanceExpression.Emit (ec);
+
+                       if (prepare_for_load)
+                               ec.ig.Emit (OpCodes.Dup);
+               }
        }
 
        /// <summary>
@@ -3363,7 +3389,7 @@
                                ig.Emit (OpCodes.Ldsfld, FieldInfo);
                        } else {
                                if (!prepared)
-                                       EmitInstance (ec);
+                                       EmitInstance (ec, false);
 
                                if (is_volatile)
                                        ig.Emit (OpCodes.Volatile);
@@ -3401,11 +3427,7 @@
                                return;
                        }
 
-                       if (!is_static) {
-                               EmitInstance (ec);
-                               if (prepare_for_load)
-                                       ig.Emit (OpCodes.Dup);
-                       }
+                       EmitInstance (ec, prepare_for_load);
 
                        source.Emit (ec);
                        if (leave_copy) {
@@ -3435,21 +3457,6 @@
                                temp.Emit (ec);
                }
 
-               void EmitInstance (EmitContext ec)
-               {
-                       if (InstanceExpression.Type.IsValueType) {
-                               if (InstanceExpression is IMemoryLocation) {
-                                       ((IMemoryLocation) 
InstanceExpression).AddressOf (ec, AddressOp.LoadStore);
-                               } else {
-                                       LocalTemporary t = new LocalTemporary 
(ec, InstanceExpression.Type);
-                                       InstanceExpression.Emit (ec);
-                                       t.Store (ec);
-                                       t.AddressOf (ec, AddressOp.Store);
-                               }
-                       } else
-                               InstanceExpression.Emit (ec);
-               }
-
                public override void Emit (EmitContext ec)
                {
                        Emit (ec, false);
@@ -3504,7 +3511,7 @@
                        if (FieldInfo.IsStatic){
                                ig.Emit (OpCodes.Ldsflda, FieldInfo);
                        } else {
-                               EmitInstance (ec);
+                               EmitInstance (ec, false);
                                ig.Emit (OpCodes.Ldflda, FieldInfo);
                        }
                }
@@ -3826,40 +3833,16 @@
 
                        return this;
                }
-
-
                
                public override void Emit (EmitContext ec)
                {
                        Emit (ec, false);
                }
                
-               void EmitInstance (EmitContext ec)
-               {
-                       if (is_static)
-                               return;
-
-                       if (InstanceExpression.Type.IsValueType) {
-                               if (InstanceExpression is IMemoryLocation) {
-                                       ((IMemoryLocation) 
InstanceExpression).AddressOf (ec, AddressOp.LoadStore);
-                               } else {
-                                       LocalTemporary t = new LocalTemporary 
(ec, InstanceExpression.Type);
-                                       InstanceExpression.Emit (ec);
-                                       t.Store (ec);
-                                       t.AddressOf (ec, AddressOp.Store);
-                               }
-                       } else
-                               InstanceExpression.Emit (ec);
-                       
-                       if (prepared)
-                               ec.ig.Emit (OpCodes.Dup);
-               }
-
-               
                public void Emit (EmitContext ec, bool leave_copy)
                {
                        if (!prepared)
-                               EmitInstance (ec);
+                               EmitInstance (ec, false);
                        
                        //
                        // Special case: length of single dimension array 
property is turned into ldlen
@@ -3898,7 +3881,7 @@
                {
                        prepared = prepare_for_load;
                        
-                       EmitInstance (ec);
+                       EmitInstance (ec, prepare_for_load);
 
                        source.Emit (ec);
                        if (leave_copy) {

Modified: trunk/mcs/gmcs/expression.cs
===================================================================
--- trunk/mcs/gmcs/expression.cs        2005-07-08 12:57:29 UTC (rev 47093)
+++ trunk/mcs/gmcs/expression.cs        2005-07-08 12:57:57 UTC (rev 47094)
@@ -5662,7 +5662,12 @@
                                return;
                        
                        if (!is_static){
-                               this_call = instance_expr == null;
+                               if (instance_expr == EmptyExpression.Null) {
+                                       SimpleName.Error_ObjectRefRequired (ec, 
loc, TypeManager.CSharpSignature (method));
+                                       return;
+                               }
+
+                               this_call = instance_expr is This;
                                if (decl_type.IsValueType || (!this_call && 
instance_expr.Type.IsValueType))
                                        struct_call = true;
 

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

Reply via email to