2004-11-02 Ben Maurer <bmaurer@ximian.com>
authorBen Maurer <benm@mono-cvs.ximian.com>
Tue, 2 Nov 2004 21:15:46 +0000 (21:15 -0000)
committerBen Maurer <benm@mono-cvs.ximian.com>
Tue, 2 Nov 2004 21:15:46 +0000 (21:15 -0000)
* expression.cs (StringConcat): Handle being called twice,
as when we have a concat in a field init with more than two
ctors in the class

svn path=/branches/mono-1-0/mcs/; revision=35581

mcs/mcs/ChangeLog
mcs/mcs/expression.cs

index e87ac343b1db3e7df43f36150f98fa479710a262..a977f8a4681cbcde6e47f856fdd5cb948fc0660a 100755 (executable)
@@ -1,3 +1,9 @@
+2004-11-02  Ben Maurer  <bmaurer@ximian.com>
+
+       * expression.cs (StringConcat): Handle being called twice,
+       as when we have a concat in a field init with more than two
+       ctors in the class
+
 2004-11-01  Miguel de Icaza  <miguel@ximian.com>
 
        * assign.cs (Assign.DoResolve): Only do the transform of
index 314578e9e9eaedd07e37260d1a169b1f77596df5..af1be64d86bcf0604f3389d24c92f1a71dbcae81 100755 (executable)
@@ -3146,7 +3146,11 @@ namespace Mono.CSharp {
        public class StringConcat : Expression {
                ArrayList operands;
                bool invalid = false;
-               
+               bool emit_conv_done = false;
+               //
+               // Are we also concating objects?
+               //
+               bool is_strings_only = true;
                
                public StringConcat (EmitContext ec, Location loc, Expression left, Expression right)
                {
@@ -3200,30 +3204,30 @@ namespace Mono.CSharp {
                {
                        MethodInfo concat_method = null;
                        
-                       //
-                       // Are we also concating objects?
-                       //
-                       bool is_strings_only = true;
-                       
                        //
                        // Do conversion to arguments; check for strings only
                        //
-                       for (int i = 0; i < operands.Count; i ++) {
-                               Expression e = (Expression) operands [i];
-                               is_strings_only &= e.Type == TypeManager.string_type;
-                       }
                        
-                       for (int i = 0; i < operands.Count; i ++) {
-                               Expression e = (Expression) operands [i];
+                       // This can get called multiple times, so we have to deal with that.
+                       if (!emit_conv_done) {
+                               emit_conv_done = true;
+                               for (int i = 0; i < operands.Count; i ++) {
+                                       Expression e = (Expression) operands [i];
+                                       is_strings_only &= e.Type == TypeManager.string_type;
+                               }
                                
-                               if (! is_strings_only && e.Type == TypeManager.string_type) {
-                                       // need to make sure this is an object, because the EmitParams
-                                       // method might look at the type of this expression, see it is a
-                                       // string and emit a string [] when we want an object [];
+                               for (int i = 0; i < operands.Count; i ++) {
+                                       Expression e = (Expression) operands [i];
                                        
-                                       e = Convert.ImplicitConversion (ec, e, TypeManager.object_type, loc);
+                                       if (! is_strings_only && e.Type == TypeManager.string_type) {
+                                               // need to make sure this is an object, because the EmitParams
+                                               // method might look at the type of this expression, see it is a
+                                               // string and emit a string [] when we want an object [];
+                                               
+                                               e = new EmptyCast (e, TypeManager.object_type);
+                                       }
+                                       operands [i] = new Argument (e, Argument.AType.Expression);
                                }
-                               operands [i] = new Argument (e, Argument.AType.Expression);
                        }
                        
                        //