Author: martin
Date: 2005-04-18 03:47:33 -0400 (Mon, 18 Apr 2005)
New Revision: 43197

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


Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog    2005-04-18 07:46:52 UTC (rev 43196)
+++ trunk/mcs/gmcs/ChangeLog    2005-04-18 07:47:33 UTC (rev 43197)
@@ -1,3 +1,14 @@
+2005-03-22  Marek Safar  <[EMAIL PROTECTED]>
+
+       * assign.cs (Assign.DoResolve): Check for CS1717 when
+       source and target are same (uses Equals).
+       
+       * expression.cs (LocalVariableReference, ParameterReference,
+       This): Implemented Equals, GetHashCode.
+       
+       * statement.cs (Block.GetParameterReference): Removed useless
+       local variable.
+
 2005-03-22  Raja R Harinath  <[EMAIL PROTECTED]>
 
        Fix cs0128.cs

Modified: trunk/mcs/gmcs/assign.cs
===================================================================
--- trunk/mcs/gmcs/assign.cs    2005-04-18 07:46:52 UTC (rev 43196)
+++ trunk/mcs/gmcs/assign.cs    2005-04-18 07:47:33 UTC (rev 43197)
@@ -350,6 +350,10 @@
                        if (target == null)
                                return null;
 
+                       if (source.Equals (target)) {
+                               Report.Warning (1717, 3, loc, "Assignment made 
to same variable; did you mean to assign something else?");
+                       }
+
                        Type target_type = target.Type;
                        Type source_type = real_source.Type;
 

Modified: trunk/mcs/gmcs/ecore.cs
===================================================================
--- trunk/mcs/gmcs/ecore.cs     2005-04-18 07:46:52 UTC (rev 43196)
+++ trunk/mcs/gmcs/ecore.cs     2005-04-18 07:47:33 UTC (rev 43197)
@@ -3119,6 +3119,26 @@
 
                        return true;
                }
+
+               public override int GetHashCode()
+               {
+                       return FieldInfo.GetHashCode ();
+               }
+
+               public override bool Equals (object obj)
+               {
+                       FieldExpr fe = obj as FieldExpr;
+                       if (fe == null)
+                               return false;
+
+                       if (FieldInfo != fe.FieldInfo)
+                               return false;
+
+                       if (InstanceExpression == null || fe.InstanceExpression 
== null)
+                               return true;
+
+                       return InstanceExpression.Equals 
(fe.InstanceExpression);
+               }
                
                public void Emit (EmitContext ec, bool leave_copy)
                {

Modified: trunk/mcs/gmcs/expression.cs
===================================================================
--- trunk/mcs/gmcs/expression.cs        2005-04-18 07:46:52 UTC (rev 43196)
+++ trunk/mcs/gmcs/expression.cs        2005-04-18 07:47:33 UTC (rev 43197)
@@ -3760,6 +3760,20 @@
                        return !is_expression || local_info.IsFixed;
                }
 
+               public override int GetHashCode()
+               {
+                       return Name.GetHashCode ();
+               }
+
+               public override bool Equals (object obj)
+               {
+                       LocalVariableReference lvr = obj as 
LocalVariableReference;
+                       if (lvr == null)
+                               return false;
+
+                       return Name == lvr.Name && Block == lvr.Block;
+               }
+
                public override void Emit (EmitContext ec)
                {
                        ILGenerator ig = ec.ig;
@@ -3958,6 +3972,20 @@
                        }
                }
 
+               public override int GetHashCode()
+               {
+                       return name.GetHashCode ();
+               }
+
+               public override bool Equals (object obj)
+               {
+                       ParameterReference pr = obj as ParameterReference;
+                       if (pr == null)
+                               return false;
+
+                       return name == pr.name && block == pr.block;
+               }
+
                //
                // Notice that for ref/out parameters, the type exposed is not 
the
                // same type exposed externally.
@@ -7089,6 +7117,20 @@
                                ig.Emit (OpCodes.Ldobj, type);
                }
 
+               public override int GetHashCode()
+               {
+                       return block.GetHashCode ();
+               }
+
+               public override bool Equals (object obj)
+               {
+                       This t = obj as This;
+                       if (t == null)
+                               return false;
+
+                       return block == t.block;
+               }
+
                public void AddressOf (EmitContext ec, AddressOp mode)
                {
                        ec.EmitThis ();

Modified: trunk/mcs/gmcs/statement.cs
===================================================================
--- trunk/mcs/gmcs/statement.cs 2005-04-18 07:46:52 UTC (rev 43196)
+++ trunk/mcs/gmcs/statement.cs 2005-04-18 07:47:33 UTC (rev 43197)
@@ -1648,10 +1648,7 @@
                                        
                                        par = pars.GetParameterByName (name, 
out idx);
                                        if (par != null){
-                                               ParameterReference pr;
-
-                                               pr = new ParameterReference 
(pars, this, idx, name, loc);
-                                               return pr;
+                                               return new ParameterReference 
(pars, this, idx, name, loc);
                                        }
                                }
                                        b = b.Parent;

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

Reply via email to