[vala] Use switch instead of do-while for string switch statements



commit 17c5f08651bb39f219b502f8732692b83636183d
Author: Luca Bruno <lethalman88 gmail com>
Date:   Thu Mar 11 13:04:26 2010 +0100

    Use switch instead of do-while for string switch statements
    
    Fixes bug 541229.

 codegen/valaccodecontrolflowmodule.vala |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/codegen/valaccodecontrolflowmodule.vala b/codegen/valaccodecontrolflowmodule.vala
index ea96d64..b8346e2 100644
--- a/codegen/valaccodecontrolflowmodule.vala
+++ b/codegen/valaccodecontrolflowmodule.vala
@@ -152,8 +152,10 @@ internal class Vala.CCodeControlFlowModule : CCodeMethodModule {
 				}
 			}
 
-			var cdo = new CCodeDoStatement (cblock, new CCodeConstant ("0"));
-			var cif = new CCodeIfStatement (cor, cdo);
+			var cswitch = new CCodeSwitchStatement (new CCodeConstant ("0"));
+			cswitch.add_statement (new CCodeLabel ("default"));
+			cswitch.add_statement (cblock);
+			var cif = new CCodeIfStatement (cor, cswitch);
 
 			if (coldif != null) {
 				coldif.false_statement = cif;
@@ -169,15 +171,17 @@ internal class Vala.CCodeControlFlowModule : CCodeMethodModule {
 			foreach (CodeNode body_stmt in default_statements) {
 				cblock.add_statement (body_stmt.ccodenode);
 			}
-		
-			var cdo = new CCodeDoStatement (cblock, new CCodeConstant ("0"));
+
+			var cswitch = new CCodeSwitchStatement (new CCodeConstant ("0"));
+			cswitch.add_statement (new CCodeLabel ("default"));
+			cswitch.add_statement (cblock);
 
 			if (coldif == null) {
 				// there is only one section and that section
 				// contains a default label
-				ctopstmt = cdo;
+				ctopstmt = cswitch;
 			} else {
-				coldif.false_statement = cdo;
+				coldif.false_statement = cswitch;
 			}
 		}
 	



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]