summaryrefslogtreecommitdiff
path: root/vala/valawhilestatement.vala
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2008-11-07 11:10:31 +0000
committerJürg Billeter <juergbi@src.gnome.org>2008-11-07 11:10:31 +0000
commit955c4f6c3e8bf120d363015897528567b2df23ed (patch)
treebfbcfdbf98058f2de5f17491ee63934b98ca8355 /vala/valawhilestatement.vala
parent4ed3719f219f7ee4d3c40544df7ec75719fae8fd (diff)
downloadvala-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/valawhilestatement.vala')
-rw-r--r--vala/valawhilestatement.vala27
1 files changed, 27 insertions, 0 deletions
diff --git a/vala/valawhilestatement.vala b/vala/valawhilestatement.vala
index 947a70831..ee3a43c67 100644
--- a/vala/valawhilestatement.vala
+++ b/vala/valawhilestatement.vala
@@ -86,4 +86,31 @@ public class Vala.WhileStatement : CodeNode, Statement {
condition = new_node;
}
}
+
+ public override bool check (SemanticAnalyzer analyzer) {
+ if (checked) {
+ return !error;
+ }
+
+ checked = true;
+
+ accept_children (analyzer);
+
+ if (condition.error) {
+ /* if there was an error in the condition, skip this check */
+ error = true;
+ return false;
+ }
+
+ if (!condition.value_type.compatible (analyzer.bool_type)) {
+ error = true;
+ Report.error (condition.source_reference, "Condition must be boolean");
+ return false;
+ }
+
+ add_error_types (condition.get_error_types ());
+ add_error_types (body.get_error_types ());
+
+ return !error;
+ }
}