2002-12-06 Miguel de Icaza <miguel@ximian.com>
authorMiguel de Icaza <miguel@gnome.org>
Fri, 6 Dec 2002 23:39:37 +0000 (23:39 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Fri, 6 Dec 2002 23:39:37 +0000 (23:39 -0000)
* expression.cs (Binary.ResolveOperator): I can only use the
Concat (string, string, string) and Concat (string, string,
string, string) if the child is actually a concatenation of
strings.

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

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

index 758b5e8ddbd156c885003e4ca2dd294119b555d7..c4a9fa6c4f3a3b89665b483e5bc4453f571a4dd3 100755 (executable)
@@ -1,3 +1,10 @@
+2002-12-06  Miguel de Icaza  <miguel@ximian.com>
+
+       * expression.cs (Binary.ResolveOperator): I can only use the
+       Concat (string, string, string) and Concat (string, string,
+       string, string) if the child is actually a concatenation of
+       strings. 
+
 2002-12-04  Miguel de Icaza  <miguel@ximian.com>
 
        * cs-tokenizer.cs: Small fix, because decimal_digits is used in a
index be4cc9d295aa62bb17ddedb1be92392628bdac61..9d71f7c0243f52a97b65f35504abf22c5b5ae0a0 100755 (executable)
@@ -2138,7 +2138,9 @@ namespace Mono.CSharp {
                                                        // String.Concat (string, string, string, string)
                                                        // if possible.
                                                        //
-                                                       if (b.oper == Operator.Addition){
+                                                       if (b.oper == Operator.Addition &&
+                                                           (b.method == TypeManager.string_concat_string_string_string ||
+                                                            b.method == TypeManager.string_concat_string_string_string_string)){
                                                                ArrayList bargs = b.Arguments;
                                                                int count = bargs.Count;
                                                                
@@ -2508,22 +2510,16 @@ namespace Mono.CSharp {
                        if (left == null || right == null)
                                return null;
 
-                       if (left.Type == null)
-                               throw new Exception (
-                                       "Resolve returned non null, but did not set the type! (" +
-                                       left + ") at Line: " + loc.Row);
-                       if (right.Type == null)
-                               throw new Exception (
-                                       "Resolve returned non null, but did not set the type! (" +
-                                       right + ") at Line: "+ loc.Row);
-
                        eclass = ExprClass.Value;
 
-                       if (left is Constant && right is Constant){
+                       Constant rc = right as Constant;
+                       Constant lc = left as Constant;
+
+                       if (rc != null & lc != null){
                                Expression e = ConstantFold.BinaryFold (
-                                       ec, oper, (Constant) left, (Constant) right, loc);
-                               if (e != null)
-                                       return e;
+                                       ec, oper, lc, rc, loc);
+                                       if (e != null)
+                                               return e;
                        }
 
                        return ResolveOperator (ec);
index ec3d4d277c50c9050e9d9ebc23aee40f0522c217..e81ab2ec5be002b4fa9039e8bde75116d538c2cc 100755 (executable)
@@ -21,7 +21,6 @@ namespace Mono.CSharp {
                Namespace parent;
                string name;
                ArrayList using_clauses;
-               Hashtable using_namespaces;
                Hashtable aliases;
                public bool DeclarationFound = false;
 
@@ -95,18 +94,16 @@ namespace Mono.CSharp {
                        if (using_clauses == null)
                                using_clauses = new ArrayList ();
 
-                       if (using_namespaces == null)
-                               using_namespaces = new Hashtable ();
-
-                       if (using_namespaces.ContainsKey (ns)) {
-                               Report.Warning (105, loc, "The using directive for '" + ns +
-                                                         "' appeared previously in this namespace");
-                               return;
+                       foreach (UsingEntry old_entry in using_clauses){
+                               if (old_entry.Name == ns){
+                                       Report.Warning (105, loc, "The using directive for '" + ns +
+                                                       "' appeared previously in this namespace");
+                                       break;
+                               }
                        }
-
+                       
                        UsingEntry ue = new UsingEntry (ns, loc);
                        using_clauses.Add (ue);
-                       using_namespaces.Add (ns, ns);
                }
 
                public ArrayList UsingTable {