diff options
author | Jürg Billeter <j@bitron.ch> | 2008-11-29 17:25:51 +0000 |
---|---|---|
committer | Jürg Billeter <juergbi@src.gnome.org> | 2008-11-29 17:25:51 +0000 |
commit | 9c112c985e1edafa2602416962702f185a5583a0 (patch) | |
tree | 00a87c40a46d3f07cf15797250d396d965d8006d /vala/valaforstatement.vala | |
parent | 44a1c2f3196261abbc0930f84df21fc877afd266 (diff) | |
download | vala-9c112c985e1edafa2602416962702f185a5583a0.tar.gz |
Convert binary conditional expressions into if statements
2008-11-29 Jürg Billeter <j@bitron.ch>
* vala/valaaddressofexpression.vala:
* vala/valaarraycreationexpression.vala:
* vala/valaassignment.vala:
* vala/valabaseaccess.vala:
* vala/valabinaryexpression.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/valasizeofexpression.vala:
* vala/valatuple.vala:
* vala/valatypecheck.vala:
* vala/valatypeofexpression.vala:
* vala/valaunaryexpression.vala:
* vala/valawhilestatement.vala:
Convert binary conditional expressions into if statements
svn path=/trunk/; revision=2085
Diffstat (limited to 'vala/valaforstatement.vala')
-rw-r--r-- | vala/valaforstatement.vala | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/vala/valaforstatement.vala b/vala/valaforstatement.vala index cf02aa726..ebd8de526 100644 --- a/vala/valaforstatement.vala +++ b/vala/valaforstatement.vala @@ -164,6 +164,20 @@ public class Vala.ForStatement : CodeNode, Statement { 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); } |