diff options
author | Jürg Billeter <j@bitron.ch> | 2008-11-07 11:10:31 +0000 |
---|---|---|
committer | Jürg Billeter <juergbi@src.gnome.org> | 2008-11-07 11:10:31 +0000 |
commit | 955c4f6c3e8bf120d363015897528567b2df23ed (patch) | |
tree | bfbcfdbf98058f2de5f17491ee63934b98ca8355 /vala/valaforstatement.vala | |
parent | 4ed3719f219f7ee4d3c40544df7ec75719fae8fd (diff) | |
download | vala-955c4f6c3e8bf120d363015897528567b2df23ed.tar.gz |
Move statement checking to code nodes
2008-11-07 Jürg Billeter <j@bitron.ch>
* vala/valablock.vala:
* vala/valacatchclause.vala:
* vala/valadeclarationstatement.vala:
* vala/valadeletestatement.vala:
* vala/valadostatement.vala:
* vala/valaexpressionstatement.vala:
* vala/valaforstatement.vala:
* vala/valaifstatement.vala:
* vala/valainitializerlist.vala:
* vala/valalocalvariable.vala:
* vala/valalockstatement.vala:
* vala/valasemanticanalyzer.vala:
* vala/valaswitchsection.vala:
* vala/valatrystatement.vala:
* vala/valawhilestatement.vala:
Move statement checking to code nodes
svn path=/trunk/; revision=2003
Diffstat (limited to 'vala/valaforstatement.vala')
-rw-r--r-- | vala/valaforstatement.vala | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/vala/valaforstatement.vala b/vala/valaforstatement.vala index 657f95c88..6e309ecdc 100644 --- a/vala/valaforstatement.vala +++ b/vala/valaforstatement.vala @@ -156,4 +156,40 @@ public class Vala.ForStatement : CodeNode, Statement { } } } + + public override bool check (SemanticAnalyzer analyzer) { + if (checked) { + return !error; + } + + checked = true; + + accept_children (analyzer); + + if (condition != null && condition.error) { + /* if there was an error in the condition, skip this check */ + error = true; + return false; + } + + if (condition != null && !condition.value_type.compatible (analyzer.bool_type)) { + error = true; + Report.error (condition.source_reference, "Condition must be boolean"); + return false; + } + + if (condition != null) { + add_error_types (condition.get_error_types ()); + } + + add_error_types (body.get_error_types ()); + foreach (Expression exp in get_initializer ()) { + add_error_types (exp.get_error_types ()); + } + foreach (Expression exp in get_iterator ()) { + add_error_types (exp.get_error_types ()); + } + + return !error; + } } |