Author: marek
Date: 2007-02-09 17:08:05 -0500 (Fri, 09 Feb 2007)
New Revision: 72556

Modified:
   trunk/mcs/mcs/statement.cs
Log:
2007-02-09  Marek Safar  <[EMAIL PROTECTED]>

        * statement.cs (Switch): Switch over boolean type is not standardized.


Modified: trunk/mcs/mcs/statement.cs
===================================================================
--- trunk/mcs/mcs/statement.cs  2007-02-09 21:12:16 UTC (rev 72555)
+++ trunk/mcs/mcs/statement.cs  2007-02-09 22:08:05 UTC (rev 72556)
@@ -3222,7 +3222,12 @@
                        bool pending_goto_end = false;
                        bool null_marked = false;
                        bool null_found;
+                       int section_count = Sections.Count;
 
+                       // TODO: implement switch optimization for string by 
using Hashtable
+                       //if (SwitchType == TypeManager.string_type && 
section_count > 7)
+                       //      Console.WriteLine ("Switch optimization 
possible " + loc);
+
                        ig.Emit (OpCodes.Ldloc, val);
                        
                        if (Elements.Contains (SwitchLabel.NullStringCase)){
@@ -3234,7 +3239,6 @@
                        ig.Emit (OpCodes.Call, 
TypeManager.string_isinterned_string);
                        ig.Emit (OpCodes.Stloc, val);
 
-                       int section_count = Sections.Count;
                        for (int section = 0; section < section_count; 
section++){
                                SwitchSection ss = (SwitchSection) Sections 
[section];
 
@@ -3342,6 +3346,11 @@
                        // Validate switch.
                        SwitchType = new_expr.Type;
 
+                       if (RootContext.Version == LanguageVersion.ISO_1 && 
SwitchType == TypeManager.bool_type) {
+                               Report.FeatureIsNotISO1 (loc, "switch 
expression of boolean type");
+                               return false;
+                       }
+
                        if (!CheckSwitch (ec))
                                return false;
 

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

Reply via email to