vala r2096 - in trunk: . gobject vala
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r2096 - in trunk: . gobject vala
- Date: Sun, 30 Nov 2008 12:50:43 +0000 (UTC)
Author: juergbi
Date: Sun Nov 30 12:50:43 2008
New Revision: 2096
URL: http://svn.gnome.org/viewvc/vala?rev=2096&view=rev
Log:
2008-11-30 JÃrg Billeter <j bitron ch>
* vala/valaaddressofexpression.vala:
* vala/valaarraycreationexpression.vala:
* vala/valaassignment.vala:
* vala/valabaseaccess.vala:
* vala/valabinaryexpression.vala:
* vala/valablock.vala:
* vala/valacastexpression.vala:
* vala/valaconditionalexpression.vala:
* vala/valadostatement.vala:
* vala/valaelementaccess.vala:
* vala/valaexpression.vala:
* vala/valaforstatement.vala:
* vala/valainitializerlist.vala:
* vala/valalambdaexpression.vala:
* vala/valaliteral.vala:
* vala/valamemberaccess.vala:
* vala/valamethodcall.vala:
* vala/valaobjectcreationexpression.vala:
* vala/valaparenthesizedexpression.vala:
* vala/valapointerindirection.vala:
* vala/valapostfixexpression.vala:
* vala/valareferencetransferexpression.vala:
* vala/valasemanticanalyzer.vala:
* vala/valasizeofexpression.vala:
* vala/valaswitchsection.vala:
* vala/valatuple.vala:
* vala/valatypecheck.vala:
* vala/valatypeofexpression.vala:
* vala/valaunaryexpression.vala:
* vala/valawhilestatement.vala:
* gobject/valaccodebasemodule.vala:
Fix error handling in condition of while, do, and for statements
Modified:
trunk/ChangeLog
trunk/gobject/valaccodebasemodule.vala
trunk/vala/valaaddressofexpression.vala
trunk/vala/valaarraycreationexpression.vala
trunk/vala/valaassignment.vala
trunk/vala/valabaseaccess.vala
trunk/vala/valabinaryexpression.vala
trunk/vala/valablock.vala
trunk/vala/valacastexpression.vala
trunk/vala/valaconditionalexpression.vala
trunk/vala/valadostatement.vala
trunk/vala/valaelementaccess.vala
trunk/vala/valaexpression.vala
trunk/vala/valaforstatement.vala
trunk/vala/valainitializerlist.vala
trunk/vala/valalambdaexpression.vala
trunk/vala/valaliteral.vala
trunk/vala/valamemberaccess.vala
trunk/vala/valamethodcall.vala
trunk/vala/valaobjectcreationexpression.vala
trunk/vala/valaparenthesizedexpression.vala
trunk/vala/valapointerindirection.vala
trunk/vala/valapostfixexpression.vala
trunk/vala/valareferencetransferexpression.vala
trunk/vala/valasemanticanalyzer.vala
trunk/vala/valasizeofexpression.vala
trunk/vala/valaswitchsection.vala
trunk/vala/valatuple.vala
trunk/vala/valatypecheck.vala
trunk/vala/valatypeofexpression.vala
trunk/vala/valaunaryexpression.vala
trunk/vala/valawhilestatement.vala
Modified: trunk/gobject/valaccodebasemodule.vala
==============================================================================
--- trunk/gobject/valaccodebasemodule.vala (original)
+++ trunk/gobject/valaccodebasemodule.vala Sun Nov 30 12:50:43 2008
@@ -1207,6 +1207,7 @@
}
public override void visit_block (Block b) {
+ var old_symbol = current_symbol;
current_symbol = b;
b.accept_children (codegen);
@@ -1258,7 +1259,7 @@
b.ccodenode = cblock;
- current_symbol = current_symbol.parent_symbol;
+ current_symbol = old_symbol;
}
public override void visit_empty_statement (EmptyStatement stmt) {
Modified: trunk/vala/valaaddressofexpression.vala
==============================================================================
--- trunk/vala/valaaddressofexpression.vala (original)
+++ trunk/vala/valaaddressofexpression.vala Sun Nov 30 12:50:43 2008
@@ -97,8 +97,4 @@
return !error;
}
-
- public override bool in_single_basic_block () {
- return inner.in_single_basic_block ();
- }
}
Modified: trunk/vala/valaarraycreationexpression.vala
==============================================================================
--- trunk/vala/valaarraycreationexpression.vala (original)
+++ trunk/vala/valaarraycreationexpression.vala Sun Nov 30 12:50:43 2008
@@ -220,13 +220,4 @@
return !error;
}
-
- public override bool in_single_basic_block () {
- foreach (Expression size in sizes) {
- if (!size.in_single_basic_block ()) {
- return false;
- }
- }
- return true;
- }
}
Modified: trunk/vala/valaassignment.vala
==============================================================================
--- trunk/vala/valaassignment.vala (original)
+++ trunk/vala/valaassignment.vala Sun Nov 30 12:50:43 2008
@@ -400,10 +400,6 @@
}
right.get_used_variables (collection);
}
-
- public override bool in_single_basic_block () {
- return left.in_single_basic_block () && right.in_single_basic_block ();
- }
}
public enum Vala.AssignmentOperator {
Modified: trunk/vala/valabaseaccess.vala
==============================================================================
--- trunk/vala/valabaseaccess.vala (original)
+++ trunk/vala/valabaseaccess.vala Sun Nov 30 12:50:43 2008
@@ -88,8 +88,4 @@
return !error;
}
-
- public override bool in_single_basic_block () {
- return true;
- }
}
Modified: trunk/vala/valabinaryexpression.vala
==============================================================================
--- trunk/vala/valabinaryexpression.vala (original)
+++ trunk/vala/valabinaryexpression.vala Sun Nov 30 12:50:43 2008
@@ -148,6 +148,9 @@
checked = true;
if (operator == BinaryOperator.AND || operator == BinaryOperator.OR) {
+ var old_insert_block = analyzer.insert_block;
+ analyzer.insert_block = prepare_condition_split (analyzer);
+
// convert conditional expression into if statement
// required for flow analysis and exception handling
@@ -172,12 +175,13 @@
var if_stmt = new IfStatement (left, true_block, false_block, source_reference);
- insert_statement ((Block) analyzer.current_symbol, decl);
- insert_statement ((Block) analyzer.current_symbol, if_stmt);
+ insert_statement (analyzer.insert_block, decl);
+ insert_statement (analyzer.insert_block, if_stmt);
if (!if_stmt.check (analyzer)) {
return false;
}
+ analyzer.insert_block = old_insert_block;
var ma = new MemberAccess.simple (local.name, source_reference);
ma.target_type = target_type;
@@ -350,14 +354,6 @@
left.get_used_variables (collection);
right.get_used_variables (collection);
}
-
- public override bool in_single_basic_block () {
- if (operator == BinaryOperator.AND
- || operator == BinaryOperator.OR) {
- return false;
- }
- return left.in_single_basic_block () && right.in_single_basic_block ();
- }
}
public enum Vala.BinaryOperator {
Modified: trunk/vala/valablock.vala
==============================================================================
--- trunk/vala/valablock.vala (original)
+++ trunk/vala/valablock.vala Sun Nov 30 12:50:43 2008
@@ -120,7 +120,9 @@
owner = analyzer.current_symbol.scope;
var old_symbol = analyzer.current_symbol;
+ var old_insert_block = analyzer.insert_block;
analyzer.current_symbol = this;
+ analyzer.insert_block = this;
for (int i = 0; i < statement_list.size; i++) {
statement_list[i].check (analyzer);
@@ -135,6 +137,7 @@
}
analyzer.current_symbol = old_symbol;
+ analyzer.insert_block = old_insert_block;
return !error;
}
Modified: trunk/vala/valacastexpression.vala
==============================================================================
--- trunk/vala/valacastexpression.vala (original)
+++ trunk/vala/valacastexpression.vala Sun Nov 30 12:50:43 2008
@@ -131,8 +131,4 @@
public override void get_used_variables (Collection<LocalVariable> collection) {
inner.get_used_variables (collection);
}
-
- public override bool in_single_basic_block () {
- return inner.in_single_basic_block ();
- }
}
Modified: trunk/vala/valaconditionalexpression.vala
==============================================================================
--- trunk/vala/valaconditionalexpression.vala (original)
+++ trunk/vala/valaconditionalexpression.vala Sun Nov 30 12:50:43 2008
@@ -105,6 +105,9 @@
checked = true;
+ var old_insert_block = analyzer.insert_block;
+ analyzer.insert_block = prepare_condition_split (analyzer);
+
// convert ternary expression into if statement
// required for flow analysis and exception handling
@@ -128,12 +131,13 @@
var if_stmt = new IfStatement (condition, true_block, false_block, source_reference);
- insert_statement ((Block) analyzer.current_symbol, decl);
- insert_statement ((Block) analyzer.current_symbol, if_stmt);
+ insert_statement (analyzer.insert_block, decl);
+ insert_statement (analyzer.insert_block, if_stmt);
if (!if_stmt.check (analyzer)) {
return false;
}
+ analyzer.insert_block = old_insert_block;
true_expression = true_local.initializer;
false_expression = false_local.initializer;
@@ -176,8 +180,4 @@
return true;
}
-
- public override bool in_single_basic_block () {
- return false;
- }
}
Modified: trunk/vala/valadostatement.vala
==============================================================================
--- trunk/vala/valadostatement.vala (original)
+++ trunk/vala/valadostatement.vala Sun Nov 30 12:50:43 2008
@@ -54,7 +54,7 @@
private Expression _condition;
private Block _body;
-
+
/**
* Creates a new do statement.
*
@@ -94,45 +94,6 @@
checked = true;
- if (!condition.in_single_basic_block ()) {
- /* move condition into the loop body to allow split
- * in multiple statements
- *
- * first = false;
- * do {
- * if (first) {
- * if (!condition) {
- * break;
- * }
- * }
- * first = true;
- * ...
- * } while (true);
- */
-
- var first_local = new LocalVariable (new ValueType (analyzer.bool_type.data_type), get_temp_name (), new BooleanLiteral (false, source_reference), source_reference);
- var first_decl = new DeclarationStatement (first_local, source_reference);
- first_decl.check (analyzer);
- var block = (Block) analyzer.current_symbol;
- block.insert_before (this, first_decl);
-
- var if_condition = new UnaryExpression (UnaryOperator.LOGICAL_NEGATION, condition, condition.source_reference);
- var true_block = new Block (condition.source_reference);
- true_block.add_statement (new BreakStatement (condition.source_reference));
- var if_stmt = new IfStatement (if_condition, true_block, null, condition.source_reference);
-
- var condition_block = new Block (condition.source_reference);
- condition_block.add_statement (if_stmt);
-
- var first_if = new IfStatement (new MemberAccess.simple (first_local.name, source_reference), condition_block, null, source_reference);
- body.insert_statement (0, first_if);
- body.insert_statement (1, new ExpressionStatement (new Assignment (new MemberAccess.simple (first_local.name, source_reference), new BooleanLiteral (true, source_reference), AssignmentOperator.SIMPLE, source_reference), source_reference));
-
- condition = new BooleanLiteral (true, source_reference);
- }
-
- body.check (analyzer);
-
if (!condition.check (analyzer)) {
/* if there was an error in the condition, skip this check */
error = true;
@@ -145,9 +106,51 @@
return false;
}
+ body.check (analyzer);
+
add_error_types (condition.get_error_types ());
add_error_types (body.get_error_types ());
return !error;
}
+
+ public Block prepare_condition_split (SemanticAnalyzer analyzer) {
+ /* move condition into the loop body to allow split
+ * in multiple statements
+ *
+ * first = false;
+ * do {
+ * if (first) {
+ * if (!condition) {
+ * break;
+ * }
+ * }
+ * first = true;
+ * ...
+ * } while (true);
+ */
+
+ var first_local = new LocalVariable (new ValueType (analyzer.bool_type.data_type), get_temp_name (), new BooleanLiteral (false, source_reference), source_reference);
+ var first_decl = new DeclarationStatement (first_local, source_reference);
+ first_decl.check (analyzer);
+ var block = (Block) analyzer.current_symbol;
+ block.insert_before (this, first_decl);
+
+ var if_condition = new UnaryExpression (UnaryOperator.LOGICAL_NEGATION, condition, condition.source_reference);
+ var true_block = new Block (condition.source_reference);
+ true_block.add_statement (new BreakStatement (condition.source_reference));
+ var if_stmt = new IfStatement (if_condition, true_block, null, condition.source_reference);
+
+ var condition_block = new Block (condition.source_reference);
+ condition_block.add_statement (if_stmt);
+
+ var first_if = new IfStatement (new MemberAccess.simple (first_local.name, source_reference), condition_block, null, source_reference);
+ body.insert_statement (0, first_if);
+ body.insert_statement (1, new ExpressionStatement (new Assignment (new MemberAccess.simple (first_local.name, source_reference), new BooleanLiteral (true, source_reference), AssignmentOperator.SIMPLE, source_reference), source_reference));
+
+ condition = new BooleanLiteral (true, source_reference);
+ condition.check (analyzer);
+
+ return condition_block;
+ }
}
Modified: trunk/vala/valaelementaccess.vala
==============================================================================
--- trunk/vala/valaelementaccess.vala (original)
+++ trunk/vala/valaelementaccess.vala Sun Nov 30 12:50:43 2008
@@ -222,13 +222,4 @@
index.get_used_variables (collection);
}
}
-
- public override bool in_single_basic_block () {
- foreach (Expression index in indices) {
- if (!index.in_single_basic_block ()) {
- return false;
- }
- }
- return container.in_single_basic_block ();
- }
}
Modified: trunk/vala/valaexpression.vala
==============================================================================
--- trunk/vala/valaexpression.vala (original)
+++ trunk/vala/valaexpression.vala Sun Nov 30 12:50:43 2008
@@ -102,13 +102,23 @@
}
}
+ public Block prepare_condition_split (SemanticAnalyzer analyzer) {
+ var while_stmt = parent_statement as WhileStatement;
+ var do_stmt = parent_statement as DoStatement;
+ var for_stmt = parent_statement as ForStatement;
+
+ if (while_stmt != null) {
+ return while_stmt.prepare_condition_split (analyzer);
+ } else if (do_stmt != null) {
+ return do_stmt.prepare_condition_split (analyzer);
+ } else if (for_stmt != null) {
+ return for_stmt.prepare_condition_split (analyzer);
+ }
+
+ return analyzer.insert_block;
+ }
+
public void insert_statement (Block block, Statement stmt) {
block.insert_before (parent_statement, stmt);
}
-
- /**
- * Returns whether this expression is guaranteed to be part of a
- * single basic block in the control flow graph.
- */
- public abstract bool in_single_basic_block ();
}
Modified: trunk/vala/valaforstatement.vala
==============================================================================
--- trunk/vala/valaforstatement.vala (original)
+++ trunk/vala/valaforstatement.vala Sun Nov 30 12:50:43 2008
@@ -164,20 +164,6 @@
checked = true;
-
- if (condition != null && !condition.in_single_basic_block ()) {
- // move condition into the loop body to allow split
- // in multiple statements
-
- var if_condition = new UnaryExpression (UnaryOperator.LOGICAL_NEGATION, condition, condition.source_reference);
- var true_block = new Block (condition.source_reference);
- true_block.add_statement (new BreakStatement (condition.source_reference));
- var if_stmt = new IfStatement (if_condition, true_block, null, condition.source_reference);
- body.insert_statement (0, if_stmt);
-
- condition = new BooleanLiteral (true, source_reference);
- }
-
foreach (Expression init_expr in initializer) {
init_expr.check (analyzer);
}
@@ -218,4 +204,20 @@
return !error;
}
+
+ public Block prepare_condition_split (SemanticAnalyzer analyzer) {
+ // move condition into the loop body to allow split
+ // in multiple statements
+
+ var if_condition = new UnaryExpression (UnaryOperator.LOGICAL_NEGATION, condition, condition.source_reference);
+ var true_block = new Block (condition.source_reference);
+ true_block.add_statement (new BreakStatement (condition.source_reference));
+ var if_stmt = new IfStatement (if_condition, true_block, null, condition.source_reference);
+ body.insert_statement (0, if_stmt);
+
+ condition = new BooleanLiteral (true, source_reference);
+ condition.check (analyzer);
+
+ return body;
+ }
}
Modified: trunk/vala/valainitializerlist.vala
==============================================================================
--- trunk/vala/valainitializerlist.vala (original)
+++ trunk/vala/valainitializerlist.vala Sun Nov 30 12:50:43 2008
@@ -170,13 +170,4 @@
return !error;
}
-
- public override bool in_single_basic_block () {
- foreach (Expression initializer in initializers) {
- if (!initializer.in_single_basic_block ()) {
- return false;
- }
- }
- return true;
- }
}
Modified: trunk/vala/valalambdaexpression.vala
==============================================================================
--- trunk/vala/valalambdaexpression.vala (original)
+++ trunk/vala/valalambdaexpression.vala Sun Nov 30 12:50:43 2008
@@ -203,8 +203,4 @@
return !error;
}
-
- public override bool in_single_basic_block () {
- return true;
- }
}
Modified: trunk/vala/valaliteral.vala
==============================================================================
--- trunk/vala/valaliteral.vala (original)
+++ trunk/vala/valaliteral.vala Sun Nov 30 12:50:43 2008
@@ -33,8 +33,4 @@
public override bool is_pure () {
return true;
}
-
- public override bool in_single_basic_block () {
- return true;
- }
}
Modified: trunk/vala/valamemberaccess.vala
==============================================================================
--- trunk/vala/valamemberaccess.vala (original)
+++ trunk/vala/valamemberaccess.vala Sun Nov 30 12:50:43 2008
@@ -551,8 +551,4 @@
collection.add (local);
}
}
-
- public override bool in_single_basic_block () {
- return inner == null || inner.in_single_basic_block ();
- }
}
Modified: trunk/vala/valamethodcall.vala
==============================================================================
--- trunk/vala/valamethodcall.vala (original)
+++ trunk/vala/valamethodcall.vala Sun Nov 30 12:50:43 2008
@@ -412,13 +412,16 @@
if (parent_node is LocalVariable || parent_node is ExpressionStatement) {
// simple statements, no side effects after method call
} else {
+ var old_insert_block = analyzer.insert_block;
+ analyzer.insert_block = prepare_condition_split (analyzer);
+
// store parent_node as we need to replace the expression in the old parent node later on
var old_parent_node = parent_node;
var local = new LocalVariable (value_type, get_temp_name (), null, source_reference);
var decl = new DeclarationStatement (local, source_reference);
- insert_statement ((Block) analyzer.current_symbol, decl);
+ insert_statement (analyzer.insert_block, decl);
var temp_access = new MemberAccess.simple (local.name, source_reference);
temp_access.target_type = target_type;
@@ -428,6 +431,8 @@
decl.check (analyzer);
temp_access.check (analyzer);
+ analyzer.insert_block = old_insert_block;
+
old_parent_node.replace_expression (this, temp_access);
}
}
@@ -450,13 +455,4 @@
arg.get_used_variables (collection);
}
}
-
- public override bool in_single_basic_block () {
- foreach (Expression arg in argument_list) {
- if (!arg.in_single_basic_block ()) {
- return false;
- }
- }
- return call.in_single_basic_block ();
- }
}
Modified: trunk/vala/valaobjectcreationexpression.vala
==============================================================================
--- trunk/vala/valaobjectcreationexpression.vala (original)
+++ trunk/vala/valaobjectcreationexpression.vala Sun Nov 30 12:50:43 2008
@@ -372,13 +372,4 @@
arg.get_used_variables (collection);
}
}
-
- public override bool in_single_basic_block () {
- foreach (Expression arg in argument_list) {
- if (!arg.in_single_basic_block ()) {
- return false;
- }
- }
- return true;
- }
}
Modified: trunk/vala/valaparenthesizedexpression.vala
==============================================================================
--- trunk/vala/valaparenthesizedexpression.vala (original)
+++ trunk/vala/valaparenthesizedexpression.vala Sun Nov 30 12:50:43 2008
@@ -112,8 +112,4 @@
public override void get_used_variables (Collection<LocalVariable> collection) {
inner.get_used_variables (collection);
}
-
- public override bool in_single_basic_block () {
- return inner.in_single_basic_block ();
- }
}
Modified: trunk/vala/valapointerindirection.vala
==============================================================================
--- trunk/vala/valapointerindirection.vala (original)
+++ trunk/vala/valapointerindirection.vala Sun Nov 30 12:50:43 2008
@@ -109,8 +109,4 @@
public override void get_used_variables (Collection<LocalVariable> collection) {
inner.get_used_variables (collection);
}
-
- public override bool in_single_basic_block () {
- return inner.in_single_basic_block ();
- }
}
Modified: trunk/vala/valapostfixexpression.vala
==============================================================================
--- trunk/vala/valapostfixexpression.vala (original)
+++ trunk/vala/valapostfixexpression.vala Sun Nov 30 12:50:43 2008
@@ -75,8 +75,4 @@
return !error;
}
-
- public override bool in_single_basic_block () {
- return true;
- }
}
Modified: trunk/vala/valareferencetransferexpression.vala
==============================================================================
--- trunk/vala/valareferencetransferexpression.vala (original)
+++ trunk/vala/valareferencetransferexpression.vala Sun Nov 30 12:50:43 2008
@@ -115,8 +115,4 @@
public override void get_used_variables (Collection<LocalVariable> collection) {
inner.get_used_variables (collection);
}
-
- public override bool in_single_basic_block () {
- return inner.in_single_basic_block ();
- }
}
Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala (original)
+++ trunk/vala/valasemanticanalyzer.vala Sun Nov 30 12:50:43 2008
@@ -37,6 +37,8 @@
public Class current_class;
public Struct current_struct;
+ public Block insert_block;
+
public DataType bool_type;
public DataType string_type;
public DataType uchar_type;
Modified: trunk/vala/valasizeofexpression.vala
==============================================================================
--- trunk/vala/valasizeofexpression.vala (original)
+++ trunk/vala/valasizeofexpression.vala Sun Nov 30 12:50:43 2008
@@ -82,8 +82,4 @@
return !error;
}
-
- public override bool in_single_basic_block () {
- return true;
- }
}
Modified: trunk/vala/valaswitchsection.vala
==============================================================================
--- trunk/vala/valaswitchsection.vala (original)
+++ trunk/vala/valaswitchsection.vala Sun Nov 30 12:50:43 2008
@@ -93,7 +93,11 @@
}
owner = analyzer.current_symbol.scope;
+
+ var old_symbol = analyzer.current_symbol;
+ var old_insert_block = analyzer.insert_block;
analyzer.current_symbol = this;
+ analyzer.insert_block = this;
foreach (Statement st in get_statements ()) {
st.check (analyzer);
@@ -103,7 +107,8 @@
local.active = false;
}
- analyzer.current_symbol = analyzer.current_symbol.parent_symbol;
+ analyzer.current_symbol = old_symbol;
+ analyzer.insert_block = old_insert_block;
return !error;
}
Modified: trunk/vala/valatuple.vala
==============================================================================
--- trunk/vala/valatuple.vala (original)
+++ trunk/vala/valatuple.vala Sun Nov 30 12:50:43 2008
@@ -43,14 +43,5 @@
public override bool is_pure () {
return false;
}
-
- public override bool in_single_basic_block () {
- foreach (Expression expr in expression_list) {
- if (!expr.in_single_basic_block ()) {
- return false;
- }
- }
- return true;
- }
}
Modified: trunk/vala/valatypecheck.vala
==============================================================================
--- trunk/vala/valatypecheck.vala (original)
+++ trunk/vala/valatypecheck.vala Sun Nov 30 12:50:43 2008
@@ -101,8 +101,4 @@
return !error;
}
-
- public override bool in_single_basic_block () {
- return expression.in_single_basic_block ();
- }
}
Modified: trunk/vala/valatypeofexpression.vala
==============================================================================
--- trunk/vala/valatypeofexpression.vala (original)
+++ trunk/vala/valatypeofexpression.vala Sun Nov 30 12:50:43 2008
@@ -84,8 +84,4 @@
return !error;
}
-
- public override bool in_single_basic_block () {
- return true;
- }
}
Modified: trunk/vala/valaunaryexpression.vala
==============================================================================
--- trunk/vala/valaunaryexpression.vala (original)
+++ trunk/vala/valaunaryexpression.vala Sun Nov 30 12:50:43 2008
@@ -241,10 +241,6 @@
inner.get_used_variables (collection);
}
}
-
- public override bool in_single_basic_block () {
- return inner.in_single_basic_block ();
- }
}
public enum Vala.UnaryOperator {
Modified: trunk/vala/valawhilestatement.vala
==============================================================================
--- trunk/vala/valawhilestatement.vala (original)
+++ trunk/vala/valawhilestatement.vala Sun Nov 30 12:50:43 2008
@@ -94,19 +94,6 @@
checked = true;
- if (!condition.in_single_basic_block ()) {
- // move condition into the loop body to allow split
- // in multiple statements
-
- var if_condition = new UnaryExpression (UnaryOperator.LOGICAL_NEGATION, condition, condition.source_reference);
- var true_block = new Block (condition.source_reference);
- true_block.add_statement (new BreakStatement (condition.source_reference));
- var if_stmt = new IfStatement (if_condition, true_block, null, condition.source_reference);
- body.insert_statement (0, if_stmt);
-
- condition = new BooleanLiteral (true, source_reference);
- }
-
condition.check (analyzer);
body.check (analyzer);
@@ -128,4 +115,21 @@
return !error;
}
+
+ public Block prepare_condition_split (SemanticAnalyzer analyzer) {
+ // move condition into the loop body to allow split
+ // in multiple statements
+
+ var if_condition = new UnaryExpression (UnaryOperator.LOGICAL_NEGATION, condition, condition.source_reference);
+ var true_block = new Block (condition.source_reference);
+ true_block.add_statement (new BreakStatement (condition.source_reference));
+ var if_stmt = new IfStatement (if_condition, true_block, null, condition.source_reference);
+ body.insert_statement (0, if_stmt);
+
+ condition = new BooleanLiteral (true, source_reference);
+ condition.check (analyzer);
+
+ return body;
+ }
}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]