vala r972 - in trunk: . gobject vala



Author: juergbi
Date: Tue Feb  5 15:12:10 2008
New Revision: 972
URL: http://svn.gnome.org/viewvc/vala?rev=972&view=rev

Log:
2008-02-05  Juerg Billeter  <j bitron ch>

	* vala/valacfgbuilder.vala, vala/valaforstatement.vala,
	  vala/valasemanticanalyzer.vala, gobject/valaccodegenerator.vala:
	  support for statements without condition, fixes bug 514548


Modified:
   trunk/ChangeLog
   trunk/gobject/valaccodegenerator.vala
   trunk/vala/valacfgbuilder.vala
   trunk/vala/valaforstatement.vala
   trunk/vala/valasemanticanalyzer.vala

Modified: trunk/gobject/valaccodegenerator.vala
==============================================================================
--- trunk/gobject/valaccodegenerator.vala	(original)
+++ trunk/gobject/valaccodegenerator.vala	Tue Feb  5 15:12:10 2008
@@ -1530,7 +1530,12 @@
 	public override void visit_for_statement (ForStatement! stmt) {
 		stmt.accept_children (this);
 
-		var cfor = new CCodeForStatement ((CCodeExpression) stmt.condition.ccodenode, (CCodeStatement) stmt.body.ccodenode);
+		CCodeExpression ccondition = null;
+		if (stmt.condition != null) {
+			ccondition = (CCodeExpression) stmt.condition.ccodenode;
+		}
+
+		var cfor = new CCodeForStatement (ccondition, (CCodeStatement) stmt.body.ccodenode);
 		stmt.ccodenode = cfor;
 		
 		foreach (Expression init_expr in stmt.get_initializer ()) {
@@ -1543,7 +1548,9 @@
 			create_temp_decl (stmt, it_expr.temp_vars);
 		}
 
-		create_temp_decl (stmt, stmt.condition.temp_vars);
+		if (stmt.condition != null) {
+			create_temp_decl (stmt, stmt.condition.temp_vars);
+		}
 	}
 
 	public override void visit_foreach_statement (ForeachStatement! stmt) {

Modified: trunk/vala/valacfgbuilder.vala
==============================================================================
--- trunk/vala/valacfgbuilder.vala	(original)
+++ trunk/vala/valacfgbuilder.vala	Tue Feb  5 15:12:10 2008
@@ -356,9 +356,13 @@
 		var condition_block = new BasicBlock ();
 		current_block.connect (condition_block);
 		current_block = condition_block;
-		current_block.add_node (stmt.condition);
+		if (stmt.condition != null) {
+			current_block.add_node (stmt.condition);
+		}
 
-		handle_errors (stmt.condition);
+		if (stmt.condition != null) {
+			handle_errors (stmt.condition);
+		}
 
 		// loop block
 		current_block = new BasicBlock ();

Modified: trunk/vala/valaforstatement.vala
==============================================================================
--- trunk/vala/valaforstatement.vala	(original)
+++ trunk/vala/valaforstatement.vala	Tue Feb  5 15:12:10 2008
@@ -30,13 +30,15 @@
 	/**
 	 * Specifies the loop condition.
 	 */
-	public Expression! condition {
+	public Expression? condition {
 		get {
 			return _condition;
 		}
 		set construct {
 			_condition = value;
-			_condition.parent_node = this;
+			if (_condition != null) {
+				_condition.parent_node = this;
+			}
 		}
 	}
 	
@@ -118,9 +120,11 @@
 			visitor.visit_end_full_expression (init_expr);
 		}
 
-		condition.accept (visitor);
-		
-		visitor.visit_end_full_expression (condition);
+		if (condition != null) {
+			condition.accept (visitor);
+
+			visitor.visit_end_full_expression (condition);
+		}
 
 		foreach (Expression it_expr in iterator) {
 			it_expr.accept (visitor);

Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala	(original)
+++ trunk/vala/valasemanticanalyzer.vala	Tue Feb  5 15:12:10 2008
@@ -915,13 +915,13 @@
 	public override void visit_for_statement (ForStatement! stmt) {
 		stmt.accept_children (this);
 
-		if (stmt.condition.error) {
+		if (stmt.condition != null && stmt.condition.error) {
 			/* if there was an error in the condition, skip this check */
 			stmt.error = true;
 			return;
 		}
 
-		if (!stmt.condition.static_type.compatible (bool_type)) {
+		if (stmt.condition != null && !stmt.condition.static_type.compatible (bool_type)) {
 			stmt.error = true;
 			Report.error (stmt.condition.source_reference, "Condition must be boolean");
 			return;



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