]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Remove unnecessary accept calls in semantic analyzer
authorJürg Billeter <j@bitron.ch>
Mon, 10 Nov 2008 22:01:51 +0000 (22:01 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Mon, 10 Nov 2008 22:01:51 +0000 (22:01 +0000)
2008-11-10  Jürg Billeter  <j@bitron.ch>

* vala/valaaddressofexpression.vala:
* vala/valaarraycreationexpression.vala:
* vala/valaassignment.vala:
* vala/valabinaryexpression.vala:
* vala/valablock.vala:
* vala/valacastexpression.vala:
* vala/valacatchclause.vala:
* vala/valaclass.vala:
* vala/valaconditionalexpression.vala:
* vala/valaconstant.vala:
* vala/valaconstructor.vala:
* vala/valacreationmethod.vala:
* vala/valadeclarationstatement.vala:
* vala/valadelegate.vala:
* vala/valadeletestatement.vala:
* vala/valadestructor.vala:
* vala/valadostatement.vala:
* vala/valaelementaccess.vala:
* vala/valaenum.vala:
* vala/valaenumvalue.vala:
* vala/valaerrorcode.vala:
* vala/valaerrordomain.vala:
* vala/valaexpressionstatement.vala:
* vala/valafield.vala:
* vala/valaforeachstatement.vala:
* vala/valaformalparameter.vala:
* vala/valaforstatement.vala:
* vala/valaifstatement.vala:
* vala/valainitializerlist.vala:
* vala/valainterface.vala:
* vala/valainvocationexpression.vala:
* vala/valalambdaexpression.vala:
* vala/valalocalvariable.vala:
* vala/valalockstatement.vala:
* vala/valamemberaccess.vala:
* vala/valamemberinitializer.vala:
* vala/valamethod.vala:
* vala/valanamespace.vala:
* vala/valaobjectcreationexpression.vala:
* vala/valaparenthesizedexpression.vala:
* vala/valapointerindirection.vala:
* vala/valapostfixexpression.vala:
* vala/valaproperty.vala:
* vala/valapropertyaccessor.vala:
* vala/valareferencetransferexpression.vala:
* vala/valareturnstatement.vala:
* vala/valasemanticanalyzer.vala:
* vala/valasignal.vala:
* vala/valasizeofexpression.vala:
* vala/valasourcefile.vala:
* vala/valastruct.vala:
* vala/valaswitchlabel.vala:
* vala/valaswitchsection.vala:
* vala/valaswitchstatement.vala:
* vala/valathrowstatement.vala:
* vala/valatrystatement.vala:
* vala/valatypecheck.vala:
* vala/valatypeofexpression.vala:
* vala/valaunaryexpression.vala:
* vala/valawhilestatement.vala:
* vala/valayieldstatement.vala:

Remove unnecessary accept calls in semantic analyzer

svn path=/trunk/; revision=2010

62 files changed:
ChangeLog
vala/valaaddressofexpression.vala
vala/valaarraycreationexpression.vala
vala/valaassignment.vala
vala/valabinaryexpression.vala
vala/valablock.vala
vala/valacastexpression.vala
vala/valacatchclause.vala
vala/valaclass.vala
vala/valaconditionalexpression.vala
vala/valaconstant.vala
vala/valaconstructor.vala
vala/valacreationmethod.vala
vala/valadeclarationstatement.vala
vala/valadelegate.vala
vala/valadeletestatement.vala
vala/valadestructor.vala
vala/valadostatement.vala
vala/valaelementaccess.vala
vala/valaenum.vala
vala/valaenumvalue.vala
vala/valaerrorcode.vala
vala/valaerrordomain.vala
vala/valaexpressionstatement.vala
vala/valafield.vala
vala/valaforeachstatement.vala
vala/valaformalparameter.vala
vala/valaforstatement.vala
vala/valaifstatement.vala
vala/valainitializerlist.vala
vala/valainterface.vala
vala/valainvocationexpression.vala
vala/valalambdaexpression.vala
vala/valalocalvariable.vala
vala/valalockstatement.vala
vala/valamemberaccess.vala
vala/valamemberinitializer.vala
vala/valamethod.vala
vala/valanamespace.vala
vala/valaobjectcreationexpression.vala
vala/valaparenthesizedexpression.vala
vala/valapointerindirection.vala
vala/valapostfixexpression.vala
vala/valaproperty.vala
vala/valapropertyaccessor.vala
vala/valareferencetransferexpression.vala
vala/valareturnstatement.vala
vala/valasemanticanalyzer.vala
vala/valasignal.vala
vala/valasizeofexpression.vala
vala/valasourcefile.vala
vala/valastruct.vala
vala/valaswitchlabel.vala
vala/valaswitchsection.vala
vala/valaswitchstatement.vala
vala/valathrowstatement.vala
vala/valatrystatement.vala
vala/valatypecheck.vala
vala/valatypeofexpression.vala
vala/valaunaryexpression.vala
vala/valawhilestatement.vala
vala/valayieldstatement.vala

index b5b677a6460d4b3da57520589de9102b7a9eeab8..9d6ab0aa2b1f438c93a49ff9d1aaf3b0adbae9cc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,69 @@
+2008-11-10  Jürg Billeter  <j@bitron.ch>
+
+       * vala/valaaddressofexpression.vala:
+       * vala/valaarraycreationexpression.vala:
+       * vala/valaassignment.vala:
+       * vala/valabinaryexpression.vala:
+       * vala/valablock.vala:
+       * vala/valacastexpression.vala:
+       * vala/valacatchclause.vala:
+       * vala/valaclass.vala:
+       * vala/valaconditionalexpression.vala:
+       * vala/valaconstant.vala:
+       * vala/valaconstructor.vala:
+       * vala/valacreationmethod.vala:
+       * vala/valadeclarationstatement.vala:
+       * vala/valadelegate.vala:
+       * vala/valadeletestatement.vala:
+       * vala/valadestructor.vala:
+       * vala/valadostatement.vala:
+       * vala/valaelementaccess.vala:
+       * vala/valaenum.vala:
+       * vala/valaenumvalue.vala:
+       * vala/valaerrorcode.vala:
+       * vala/valaerrordomain.vala:
+       * vala/valaexpressionstatement.vala:
+       * vala/valafield.vala:
+       * vala/valaforeachstatement.vala:
+       * vala/valaformalparameter.vala:
+       * vala/valaforstatement.vala:
+       * vala/valaifstatement.vala:
+       * vala/valainitializerlist.vala:
+       * vala/valainterface.vala:
+       * vala/valainvocationexpression.vala:
+       * vala/valalambdaexpression.vala:
+       * vala/valalocalvariable.vala:
+       * vala/valalockstatement.vala:
+       * vala/valamemberaccess.vala:
+       * vala/valamemberinitializer.vala:
+       * vala/valamethod.vala:
+       * vala/valanamespace.vala:
+       * vala/valaobjectcreationexpression.vala:
+       * vala/valaparenthesizedexpression.vala:
+       * vala/valapointerindirection.vala:
+       * vala/valapostfixexpression.vala:
+       * vala/valaproperty.vala:
+       * vala/valapropertyaccessor.vala:
+       * vala/valareferencetransferexpression.vala:
+       * vala/valareturnstatement.vala:
+       * vala/valasemanticanalyzer.vala:
+       * vala/valasignal.vala:
+       * vala/valasizeofexpression.vala:
+       * vala/valasourcefile.vala:
+       * vala/valastruct.vala:
+       * vala/valaswitchlabel.vala:
+       * vala/valaswitchsection.vala:
+       * vala/valaswitchstatement.vala:
+       * vala/valathrowstatement.vala:
+       * vala/valatrystatement.vala:
+       * vala/valatypecheck.vala:
+       * vala/valatypeofexpression.vala:
+       * vala/valaunaryexpression.vala:
+       * vala/valawhilestatement.vala:
+       * vala/valayieldstatement.vala:
+
+       Remove unnecessary accept calls in semantic analyzer
+
 2008-11-10  Jürg Billeter  <j@bitron.ch>
 
        * vala/valaaddressofexpression.vala:
index 38781bb89329eef2008c2e0d8eaa2ab363f6c6a3..4874a2b0a89dcb3c58fff0de2e8d4a494ee45493 100644 (file)
@@ -77,7 +77,8 @@ public class Vala.AddressofExpression : Expression {
 
                checked = true;
 
-               if (inner.error) {
+               if (!inner.check (analyzer)) {
+                       error = true;
                        return false;
                }
                if (!(inner.value_type is ValueType
index 0c68c435d503540e60e32d4bb1384ebeb0b485be..48fbc086f7f330378b25bd43bc90ba7468e7be61 100644 (file)
@@ -109,7 +109,7 @@ public class Vala.ArrayCreationExpression : Expression {
 
        private int create_sizes_from_initializer_list (SemanticAnalyzer analyzer, InitializerList il, int rank, Gee.List<Literal> sl) {
                var init = new IntegerLiteral (il.size.to_string (), il.source_reference);
-               init.accept (analyzer);
+               init.check (analyzer);
                sl.add (init);
 
                int subsize = -1;
@@ -155,18 +155,18 @@ public class Vala.ArrayCreationExpression : Expression {
                var initlist = initializer_list;
 
                if (element_type != null) {
-                       element_type.accept (analyzer);
+                       element_type.check (analyzer);
                }
 
                foreach (Expression e in size) {
-                       e.accept (analyzer);
+                       e.check (analyzer);
                }
 
                var calc_sizes = new ArrayList<Literal> ();
                if (initlist != null) {
                        initlist.target_type = new ArrayType (element_type, rank, source_reference);
 
-                       initlist.accept (analyzer);
+                       initlist.check (analyzer);
 
                        var ret = create_sizes_from_initializer_list (analyzer, initlist, rank, calc_sizes);
                        if (ret == -1) {
index 2985ca4d90e6108911b32a2c2394a39fcda629fa..04af2b659c9ff4d43bb2d041edf51731688f58af 100644 (file)
@@ -107,9 +107,7 @@ public class Vala.Assignment : Expression {
 
                left.lvalue = true;
 
-               left.accept (analyzer);
-
-               if (left.error) {
+               if (!left.check (analyzer)) {
                        // skip on error in inner expression
                        error = true;
                        return false;
@@ -161,9 +159,7 @@ public class Vala.Assignment : Expression {
                        return false;
                }
 
-               right.accept (analyzer);
-
-               if (right.error) {
+               if (!right.check (analyzer)) {
                        // skip on error in inner expression
                        error = true;
                        return false;
@@ -207,7 +203,7 @@ public class Vala.Assignment : Expression {
                                }
 
                                right = bin;
-                               right.accept (analyzer);
+                               right.check (analyzer);
 
                                operator = AssignmentOperator.SIMPLE;
                        }
@@ -365,7 +361,7 @@ public class Vala.Assignment : Expression {
                                 * increment calls */
                        }
                } else {
-                       return false;
+                       return true;
                }
 
                if (left.value_type != null) {
index 4eafb98321ff2bb553878845afbe862e201ed628..a3743c715ed9c7b2e5a1a326018103e985d480f8 100644 (file)
@@ -145,7 +145,7 @@ public class Vala.BinaryExpression : Expression {
 
                checked = true;
 
-               if (left.error || right.error) {
+               if (!left.check (analyzer) || !right.check (analyzer)) {
                        /* if there were any errors in inner expressions, skip type check */
                        error = true;
                        return false;
index 7f050e3147c422423f0d14c85ed0cd45189ced25..d715b74ccbeec750b8f6369a3ce4c4f273fde7f6 100644 (file)
@@ -101,13 +101,15 @@ public class Vala.Block : Symbol, Statement {
                owner = analyzer.current_symbol.scope;
                analyzer.current_symbol = this;
 
-               accept_children (analyzer);
+               foreach (Statement stmt in statement_list) {
+                       stmt.check (analyzer);
+               }
 
                foreach (LocalVariable local in get_local_variables ()) {
                        local.active = false;
                }
 
-               foreach (Statement stmt in get_statements()) {
+               foreach (Statement stmt in get_statements ()) {
                        add_error_types (stmt.get_error_types ());
                }
 
index 5703815f6cb196f1e136ee69c13b73deb99dc614..d94041ca3d22c2f5423615f68b3db77dbd497119 100644 (file)
@@ -105,11 +105,13 @@ public class Vala.CastExpression : Expression {
 
                checked = true;
 
-               if (inner.error) {
+               if (!inner.check (analyzer)) {
                        error = true;
                        return false;
                }
 
+               type_reference.check (analyzer);
+
                // FIXME: check whether cast is allowed
 
                analyzer.current_source_file.add_type_dependency (type_reference, SourceFileDependencyType.SOURCE);
index 0f141103271375a999c761b8a55341ad69fb504c..0cb7d018972979db731126d09dca1ae2bdb89613 100644 (file)
@@ -113,7 +113,9 @@ public class Vala.CatchClause : CodeNode {
                        error_type = new ErrorType (null, null, source_reference);
                }
 
-               accept_children (analyzer);
+               error_type.check (analyzer);
+
+               body.check (analyzer);
 
                return !error;
        }
index 9baec15df96b244479914b787b0fee25707e5af9..297ec0251b274eb0235fb0b6f243d38e6513f007 100644 (file)
@@ -884,7 +884,66 @@ public class Vala.Class : ObjectTypeSymbol {
                        analyzer.current_source_file.add_type_dependency (base_type_reference, SourceFileDependencyType.HEADER_FULL);
                }
 
-               accept_children (analyzer);
+               foreach (DataType type in base_types) {
+                       type.check (analyzer);
+               }
+
+               foreach (TypeParameter p in type_parameters) {
+                       p.check (analyzer);
+               }
+
+               /* process enums first to avoid order problems in C code */
+               foreach (Enum en in enums) {
+                       en.check (analyzer);
+               }
+
+               foreach (Field f in fields) {
+                       f.check (analyzer);
+               }
+               
+               foreach (Constant c in constants) {
+                       c.check (analyzer);
+               }
+               
+               foreach (Method m in methods) {
+                       m.check (analyzer);
+               }
+               
+               foreach (Property prop in properties) {
+                       prop.check (analyzer);
+               }
+               
+               foreach (Signal sig in signals) {
+                       sig.check (analyzer);
+               }
+               
+               if (constructor != null) {
+                       constructor.check (analyzer);
+               }
+
+               if (class_constructor != null) {
+                       class_constructor.check (analyzer);
+               }
+
+               if (static_constructor != null) {
+                       static_constructor.check (analyzer);
+               }
+
+               if (destructor != null) {
+                       destructor.check (analyzer);
+               }
+               
+               foreach (Class cl in classes) {
+                       cl.check (analyzer);
+               }
+               
+               foreach (Struct st in structs) {
+                       st.check (analyzer);
+               }
+
+               foreach (Delegate d in delegates) {
+                       d.check (analyzer);
+               }
 
                /* compact classes cannot implement interfaces */
                if (is_compact) {
index e0d6651810395d36995d41917c1e5b9d95097a15..0ba4a859a285bebe0191b5288d19e2b4583c9161 100644 (file)
@@ -77,7 +77,7 @@ public class Vala.ConditionalExpression : Expression {
 
                checked = true;
 
-               if (condition.error || false_expression.error || true_expression.error) {
+               if (!condition.check (analyzer) || !false_expression.check (analyzer) || !true_expression.check (analyzer)) {
                        return false;
                }
 
index 4dfac387c4bbbe47082c5a258dff68a58214cbd6..555531e29b02ef68d93d3702d8a19dfe85673d58 100644 (file)
@@ -160,7 +160,7 @@ public class Vala.Constant : Member, Lockable {
 
                process_attributes ();
 
-               type_reference.accept (analyzer);
+               type_reference.check (analyzer);
 
                if (!external_package) {
                        if (initializer == null) {
@@ -169,7 +169,7 @@ public class Vala.Constant : Member, Lockable {
                        } else {
                                initializer.target_type = type_reference;
 
-                               initializer.accept (analyzer);
+                               initializer.check (analyzer);
                        }
                }
 
index a9de8a818b9380269887561d7811ad8792890441..a09027a75c1235d595381cfbd15e82615a55ba2d 100644 (file)
@@ -74,7 +74,9 @@ public class Vala.Constructor : Symbol {
                owner = analyzer.current_symbol.scope;
                analyzer.current_symbol = this;
 
-               accept_children (analyzer);
+               if (body != null) {
+                       body.check (analyzer);
+               }
 
                foreach (DataType body_error_type in body.get_error_types ()) {
                        Report.warning (body_error_type.source_reference, "unhandled error `%s'".printf (body_error_type.to_string()));
index f7dfe265dfabdeba88360b930ebe464d16e82a6f..3f183cd0e2cf8953bcbac970d908b377f83d2f6a 100644 (file)
@@ -137,7 +137,17 @@ public class Vala.CreationMethod : Method {
                analyzer.current_symbol = this;
                analyzer.current_return_type = return_type;
 
-               accept_children (analyzer);
+               foreach (FormalParameter param in get_parameters()) {
+                       param.check (analyzer);
+               }
+
+               foreach (DataType error_type in get_error_types ()) {
+                       error_type.check (analyzer);
+               }
+
+               if (body != null) {
+                       body.check (analyzer);
+               }
 
                analyzer.current_symbol = old_symbol;
                analyzer.current_return_type = old_return_type;
index d29c0d6e4dccd7f800197e7b35279745d3b8bcaa..a11449892066ce321bfdd655fcc162188873978f 100644 (file)
@@ -56,6 +56,8 @@ public class Vala.DeclarationStatement : CodeNode, Statement {
 
                checked = true;
 
+               declaration.check (analyzer);
+
                var local = declaration as LocalVariable;
                if (local != null && local.initializer != null) {
                        foreach (DataType error_type in local.initializer.get_error_types ()) {
index 25973d6f82af0d9e27e037a73ff84c553d2cb5d8..89e723e28dd1c3c8cf00b728616a83069924ccad 100644 (file)
@@ -343,7 +343,15 @@ public class Vala.Delegate : TypeSymbol {
                        analyzer.current_source_file = source_reference.file;
                }
 
-               accept_children (analyzer);
+               foreach (TypeParameter p in type_parameters) {
+                       p.check (analyzer);
+               }
+               
+               return_type.check (analyzer);
+               
+               foreach (FormalParameter param in parameters) {
+                       param.check (analyzer);
+               }
 
                analyzer.current_source_file = old_source_file;
 
index 3bbdd6283124fa5597e9b272867296410d3f0373..e9840843764c269e27efbc449538a33527291517 100644 (file)
@@ -51,9 +51,7 @@ public class Vala.DeleteStatement : CodeNode, Statement {
 
                checked = true;
 
-               accept_children (analyzer);
-
-               if (expression.error) {
+               if (!expression.check (analyzer)) {
                        // if there was an error in the inner expression, skip this check
                        return false;
                }
index b2eba7d0e1b2d86368c5d7ed8d228c22398193fd..fd4cf4204c526b3faf4e49ea00eaf75648354882 100644 (file)
@@ -71,7 +71,9 @@ public class Vala.Destructor : Symbol {
                owner = analyzer.current_symbol.scope;
                analyzer.current_symbol = this;
 
-               accept_children (analyzer);
+               if (body != null) {
+                       body.check (analyzer);
+               }
 
                analyzer.current_symbol = analyzer.current_symbol.parent_symbol;
 
index 73db90d41d07741134d36b0fc4f5c8495dcb687a..8700c883c09771909f9f412443e3b6b4f34d9625 100644 (file)
@@ -94,9 +94,9 @@ public class Vala.DoStatement : CodeNode, Statement {
 
                checked = true;
 
-               accept_children (analyzer);
+               body.check (analyzer);
 
-               if (condition.error) {
+               if (!condition.check (analyzer)) {
                        /* if there was an error in the condition, skip this check */
                        error = true;
                        return false;
index 0734944d4a5046f116ced24b1aaeb420054deabe..296103b25a5ef04dae1ff8bdfc3cf160f69b69c8 100644 (file)
@@ -93,7 +93,7 @@ public class Vala.ElementAccess : Expression {
 
                checked = true;
 
-               container.accept (analyzer);
+               container.check (analyzer);
 
                if (container.value_type == null) {
                        /* don't proceed if a child expression failed */
@@ -114,7 +114,7 @@ public class Vala.ElementAccess : Expression {
                }
 
                foreach (Expression index in get_indices ()) {
-                       index.accept (analyzer);
+                       index.check (analyzer);
                }
 
                bool index_int_type_check = true;
index 526cd4dac677c1c2ee4e55abca182b0530042695..d1da55e682941c598b82e74580e2b05e93957f65 100644 (file)
@@ -313,7 +313,13 @@ public class Vala.Enum : TypeSymbol {
                        analyzer.current_source_file = source_reference.file;
                }
 
-               accept_children (analyzer);
+               foreach (EnumValue value in values) {
+                       value.check (analyzer);
+               }
+
+               foreach (Method m in methods) {
+                       m.check (analyzer);
+               }
 
                analyzer.current_source_file = old_source_file;
 
index 644c17bf2baca40a44056c27070ad12a7a2cf050..2e9abd2369d1d725f74c5356913ceca2a1a679b2 100644 (file)
@@ -138,7 +138,9 @@ public class Vala.EnumValue : Symbol {
 
                process_attributes ();
 
-               accept_children (analyzer);
+               if (value != null) {
+                       value.check (analyzer);
+               }
 
                return !error;
        }
index 840d4b885ee41d93351b6aa41ae6324dbb85bfa9..e46328f1642091ee3ed29f5f25d5b85b89a8c6f6 100644 (file)
@@ -80,7 +80,9 @@ public class Vala.ErrorCode : TypeSymbol {
 
                checked = true;
 
-               accept_children (analyzer);
+               if (value != null) {
+                       value.check (analyzer);
+               }
 
                return !error;
        }
index 7f061ec399d6b8fd6ad0e59f53c3fdb94d196cf0..92ec0b39be0646db7e5b395bc0a723f546cb9ee1 100644 (file)
@@ -225,7 +225,13 @@ public class Vala.ErrorDomain : TypeSymbol {
 
                process_attributes ();
 
-               accept_children (analyzer);
+               foreach (ErrorCode ecode in codes) {
+                       ecode.check (analyzer);
+               }
+
+               foreach (Method m in methods) {
+                       m.check (analyzer);
+               }
 
                return !error;
        }
index 179b8078caa56b669925c146ac76776d5df6e7a6..6dc66df31df1111105e39b0553121bae7287b90f 100644 (file)
@@ -93,7 +93,7 @@ public class Vala.ExpressionStatement : CodeNode, Statement {
 
                checked = true;
 
-               if (expression.error) {
+               if (!expression.check (analyzer)) {
                        // ignore inner error
                        error = true;
                        return false;
index 9feb2826a64ad72651b288d5ab0f0445bf59a6c2..2b9fd1fc6c37e75c3cd241d36c40f85f265f659a 100644 (file)
@@ -211,7 +211,11 @@ public class Vala.Field : Member, Lockable {
                        initializer.target_type = field_type;
                }
 
-               accept_children (analyzer);
+               field_type.check (analyzer);
+               
+               if (initializer != null) {
+                       initializer.check (analyzer);
+               }
 
                if (binding == MemberBinding.INSTANCE && parent_symbol is Interface) {
                        error = true;
index 2e53d5c7a8213742172fc16d53318d326f320e90..949445bfdaef24d1b05817d4c38b23587059b91f 100644 (file)
@@ -143,9 +143,7 @@ public class Vala.ForeachStatement : Block {
                checked = true;
 
                // analyze collection expression first, used for type inference
-               collection.accept (analyzer);
-
-               if (collection.error) {
+               if (!collection.check (analyzer)) {
                        // ignore inner error
                        error = true;
                        return false;
@@ -230,7 +228,7 @@ public class Vala.ForeachStatement : Block {
                owner = analyzer.current_symbol.scope;
                analyzer.current_symbol = this;
 
-               body.accept (analyzer);
+               body.check (analyzer);
 
                foreach (LocalVariable local in get_local_variables ()) {
                        local.active = false;
index b5733945c804f75a9f4c8a29676fa01dd475e1eb..418309c9f6812fd2570f7fd5f5bcd95a3378c44a 100644 (file)
@@ -188,7 +188,13 @@ public class Vala.FormalParameter : Symbol {
                        parameter_type.check (analyzer);
                }
 
-               accept_children (analyzer);
+               if (!ellipsis) {
+                       parameter_type.check (analyzer);
+                       
+                       if (default_expression != null) {
+                               default_expression.check (analyzer);
+                       }
+               }
 
                if (analyzer.context.non_null && default_expression != null) {
                        if (default_expression is NullLiteral
index 6e309ecdccefac0eb6456d9b733c2dc1a64f2bf3..cf02aa726b3054b0e5bf14d60f93596f387ff6a7 100644 (file)
@@ -164,7 +164,19 @@ public class Vala.ForStatement : CodeNode, Statement {
 
                checked = true;
 
-               accept_children (analyzer);
+               foreach (Expression init_expr in initializer) {
+                       init_expr.check (analyzer);
+               }
+
+               if (condition != null) {
+                       condition.check (analyzer);
+               }
+
+               foreach (Expression it_expr in iterator) {
+                       it_expr.check (analyzer);
+               }
+               
+               body.check (analyzer);
 
                if (condition != null && condition.error) {
                        /* if there was an error in the condition, skip this check */
index 4602097c19165ab2b3aee5bd8ebdd87093a9d5cf..4a97f81c1896914ca1540178241c1d63d0eb22d9 100644 (file)
@@ -94,7 +94,12 @@ public class Vala.IfStatement : CodeNode, Statement {
 
                checked = true;
 
-               accept_children (analyzer);
+               condition.check (analyzer);
+
+               true_statement.check (analyzer);
+               if (false_statement != null) {
+                       false_statement.check (analyzer);
+               }
 
                if (condition.error) {
                        /* if there was an error in the condition, skip this check */
index b6a58d5d727f049f2df4a81ea7bdd444635f92df..4b10f160734e58fc111003bb6727cd4e086396a0 100644 (file)
@@ -142,7 +142,9 @@ public class Vala.InitializerList : Expression {
                        return false;
                }
 
-               accept_children (analyzer);
+               foreach (Expression expr in initializers) {
+                       expr.check (analyzer);
+               }
 
                bool error = false;
                foreach (Expression e in get_initializers ()) {
index 195582cb3d32acb32baa54671739c7903080af3a..51ba8c0a3feb38fd6de945736218f9d01e66198c 100644 (file)
@@ -590,7 +590,45 @@ public class Vala.Interface : ObjectTypeSymbol {
                        }
                }
 
-               accept_children (analyzer);
+               foreach (DataType type in prerequisites) {
+                       type.check (analyzer);
+               }
+
+               foreach (TypeParameter p in type_parameters) {
+                       p.check (analyzer);
+               }
+
+               foreach (Enum en in enums) {
+                       en.check (analyzer);
+               }
+
+               foreach (Method m in methods) {
+                       m.check (analyzer);
+               }
+               
+               foreach (Field f in fields) {
+                       f.check (analyzer);
+               }
+               
+               foreach (Property prop in properties) {
+                       prop.check (analyzer);
+               }
+               
+               foreach (Signal sig in signals) {
+                       sig.check (analyzer);
+               }
+               
+               foreach (Class cl in classes) {
+                       cl.check (analyzer);
+               }
+               
+               foreach (Struct st in structs) {
+                       st.check (analyzer);
+               }
+
+               foreach (Delegate d in delegates) {
+                       d.check (analyzer);
+               }
 
                analyzer.current_source_file = old_source_file;
                analyzer.current_symbol = old_symbol;
index 63fdab9c565fc26aa03e800d030a44030ea82d4a..834ea46c044b4bea8409e3c0444194db54d67cb3 100644 (file)
@@ -128,9 +128,7 @@ public class Vala.InvocationExpression : Expression {
 
                checked = true;
 
-               call.accept (analyzer);
-
-               if (call.error) {
+               if (!call.check (analyzer)) {
                        /* if method resolving didn't succeed, skip this check */
                        error = true;
                        return false;
@@ -172,7 +170,7 @@ public class Vala.InvocationExpression : Expression {
                        struct_creation_expression.target_type = target_type;
                        analyzer.replaced_nodes.add (this);
                        parent_node.replace_expression (this, struct_creation_expression);
-                       struct_creation_expression.accept (analyzer);
+                       struct_creation_expression.check (analyzer);
                        return false;
                } else if (call is MemberAccess
                           && call.symbol_reference is CreationMethod) {
@@ -360,7 +358,7 @@ public class Vala.InvocationExpression : Expression {
                }
 
                foreach (Expression arg in get_argument_list ()) {
-                       arg.accept (analyzer);
+                       arg.check (analyzer);
                }
 
                DataType ret_type;
index 3cd074cfa7be6ac2fb3004fb97f5e590d5e5a2f9..52415a91591d209e88fb3408d4106b821d405f19 100644 (file)
@@ -189,7 +189,15 @@ public class Vala.LambdaExpression : Expression {
                /* lambda expressions should be usable like MemberAccess of a method */
                symbol_reference = method;
 
-               accept_children (analyzer);
+               if (method == null) {
+                       if (expression_body != null) {
+                               expression_body.check (analyzer);
+                       } else if (statement_body != null) {
+                               statement_body.check (analyzer);
+                       }
+               } else {
+                       method.check (analyzer);
+               }
 
                value_type = new MethodType (method);
 
index 1f1e922b9df80f9ef1d9dbf47d3ecd20b174647c..0b05d91a250acb8d2693bfdb1d8509c85bbf0e13 100644 (file)
@@ -110,7 +110,13 @@ public class Vala.LocalVariable : Symbol {
                        initializer.target_type = variable_type;
                }
 
-               accept_children (analyzer);
+               if (initializer != null) {
+                       initializer.check (analyzer);
+               }
+               
+               if (variable_type != null) {
+                       variable_type.check (analyzer);
+               }
 
                if (variable_type == null) {
                        /* var type */
index 49a0224c7a9ea0dbb67f1ddbc0ecbeba16bd7577..8f9b5a592d2c61f89a321c6969de4b5faf01213c 100644 (file)
@@ -55,6 +55,9 @@ public class Vala.LockStatement : CodeNode, Statement {
 
                checked = true;
 
+               resource.check (analyzer);
+               body.check (analyzer);
+
                /* resource must be a member access and denote a Lockable */
                if (!(resource is MemberAccess && resource.symbol_reference is Lockable)) {
                        error = true;
index 896236f15c28f51ef0eecd8ecbccdea1e8602300..7d5bacf42d6d0f6a2b60fd9a203498227f8db997 100644 (file)
@@ -182,6 +182,14 @@ public class Vala.MemberAccess : Expression {
 
                checked = true;
 
+               if (inner != null) {
+                       inner.check (analyzer);
+               }
+               
+               foreach (DataType type_arg in type_argument_list) {
+                       type_arg.check (analyzer);
+               }
+
                Symbol base_symbol = null;
                FormalParameter this_parameter = null;
                bool may_access_instance_members = false;
@@ -257,7 +265,7 @@ public class Vala.MemberAccess : Expression {
                                if (pointer_type != null && pointer_type.base_type is ValueType) {
                                        // transform foo->bar to (*foo).bar
                                        inner = new PointerIndirection (inner, source_reference);
-                                       inner.accept (analyzer);
+                                       inner.check (analyzer);
                                        pointer_member_access = false;
                                }
                        }
index 55ab7b598e81c5f72889296e1296507139bc4b98..3ca96b629106011d75020c04e13d4cf7fb47ec3e 100644 (file)
@@ -59,5 +59,9 @@ public class Vala.MemberInitializer : CodeNode {
        public override void accept (CodeVisitor visitor) {
                initializer.accept (visitor);
        }
+       
+       public override bool check (SemanticAnalyzer analyzer) {
+               return initializer.check (analyzer);
+       }
 }
 
index c6f3e2b53ae3323253016bf734fd850509d6966b..a91412ac87594e7638631fb0bcb3eba4ec136897 100644 (file)
@@ -668,7 +668,33 @@ public class Vala.Method : Member {
                }
                analyzer.current_source_file.add_type_dependency (return_type, SourceFileDependencyType.SOURCE);
 
-               accept_children (analyzer);
+               if (return_type != null) {
+                       return_type.check (analyzer);
+               }
+
+               foreach (FormalParameter param in parameters) {
+                       param.check (analyzer);
+               }
+
+               foreach (DataType error_type in get_error_types ()) {
+                       error_type.check (analyzer);
+               }
+
+               if (result_var != null) {
+                       result_var.variable_type.check (analyzer);
+               }
+
+               foreach (Expression precondition in preconditions) {
+                       precondition.check (analyzer);
+               }
+
+               foreach (Expression postcondition in postconditions) {
+                       postcondition.check (analyzer);
+               }
+
+               if (body != null) {
+                       body.check (analyzer);
+               }
 
                analyzer.current_symbol = old_symbol;
                analyzer.current_return_type = old_return_type;
index d84b9dff80b084a8aa7b8f226fb2d90527d89181..2a46ec7f72e5fc22d29cc18f769b81ac2dd7ce78 100644 (file)
@@ -525,6 +525,10 @@ public class Vala.Namespace : Symbol {
 
                process_attributes ();
 
+               foreach (Namespace ns in namespaces) {
+                       ns.check (analyzer);
+               }
+
                return !error;
        }
 }
index c458c042aece6152343061e221d5ee39ea064832..0e42c10981f22ada2dd8a72aae5849df1818bbce 100644 (file)
@@ -158,7 +158,7 @@ public class Vala.ObjectCreationExpression : Expression {
                checked = true;
 
                if (member_name != null) {
-                       member_name.accept (analyzer);
+                       member_name.check (analyzer);
                }
 
                TypeSymbol type = null;
@@ -311,7 +311,7 @@ public class Vala.ObjectCreationExpression : Expression {
                        }
 
                        foreach (Expression arg in args) {
-                               arg.accept (analyzer);
+                               arg.check (analyzer);
                        }
 
                        analyzer.check_arguments (this, new MethodType (m), m.get_parameters (), args);
@@ -324,7 +324,21 @@ public class Vala.ObjectCreationExpression : Expression {
                                add_error_type (call_error_type);
                        }
                } else if (type_reference is ErrorType) {
-                       accept_children (analyzer);
+                       if (type_reference != null) {
+                               type_reference.check (analyzer);
+                       }
+
+                       if (member_name != null) {
+                               member_name.check (analyzer);
+                       }
+               
+                       foreach (Expression arg in argument_list) {
+                               arg.check (analyzer);
+                       }
+
+                       foreach (MemberInitializer init in object_initializer) {
+                               init.check (analyzer);
+                       }
 
                        if (get_argument_list ().size == 0) {
                                error = true;
index c7e2dd5af57bd365c4a1a312ebe67a44f1269719..e6d0a2ebd601a12c5655b7f5e16a6caf3111c8ec 100644 (file)
@@ -82,9 +82,7 @@ public class Vala.ParenthesizedExpression : Expression {
 
                inner.target_type = target_type;
 
-               accept_children (analyzer);
-
-               if (inner.error) {
+               if (!inner.check (analyzer)) {
                        // ignore inner error
                        error = true;
                        return false;
index 7ea1354dd26fad68002cb8fc37e52345d9692880..01a27fa9418778dc61bcfe55e555aa6064fea81b 100644 (file)
@@ -77,7 +77,7 @@ public class Vala.PointerIndirection : Expression {
 
                checked = true;
 
-               if (inner.error) {
+               if (!inner.check (analyzer)) {
                        return false;
                }
                if (inner.value_type == null) {
index c1d8eba6fa8d04daec745fcf9a046d3f2bbb8db6..3ff4d6d69d59e9adaa79e209108d141ff4278780 100644 (file)
@@ -69,6 +69,8 @@ public class Vala.PostfixExpression : Expression {
 
                checked = true;
 
+               inner.check (analyzer);
+
                value_type = inner.value_type;
 
                return !error;
index 3dc081174fffb67cbbab6e63615900f55bd30bf5..c8fb63f475e111681bb9ef3c00f00e043017f6de 100644 (file)
@@ -424,14 +424,14 @@ public class Vala.Property : Member, Lockable {
                property_type.check (analyzer);
 
                if (get_accessor != null) {
-                       get_accessor.accept (analyzer);
+                       get_accessor.check (analyzer);
                }
                if (set_accessor != null) {
-                       set_accessor.accept (analyzer);
+                       set_accessor.check (analyzer);
                }
 
                if (default_expression != null) {
-                       default_expression.accept (analyzer);
+                       default_expression.check (analyzer);
                }
 
                // check whether property type is at least as accessible as the property
index 22069b65dcac84192b34863d90ef75d7f91b779d..02ad79cd878fb71c42ebccef3026a9d624de6615 100644 (file)
@@ -176,7 +176,9 @@ public class Vala.PropertyAccessor : CodeNode {
                        }
                }
 
-               accept_children (analyzer);
+               if (body != null) {
+                       body.check (analyzer);
+               }
 
                analyzer.current_return_type = old_return_type;
 
index 71b965ac6f43ad1e7cf574384765855e4e32017c..e30815ae28be00142da9249245787e18f4607642 100644 (file)
@@ -81,7 +81,7 @@ public class Vala.ReferenceTransferExpression : Expression {
 
                inner.lvalue = true;
 
-               accept_children (analyzer);
+               inner.check (analyzer);
 
                if (inner.error) {
                        /* if there was an error in the inner expression, skip type check */
index 8ea4a7d6d8150eb94b4922f7ae8df99a53cb1eab..acea142917b4c2754d779f55514c0bc013894261 100644 (file)
@@ -82,9 +82,7 @@ public class Vala.ReturnStatement : CodeNode, Statement {
                        return_expression.target_type = analyzer.current_return_type;
                }
 
-               accept_children (analyzer);
-
-               if (return_expression != null && return_expression.error) {
+               if (return_expression != null && !return_expression.check (analyzer)) {
                        // ignore inner error
                        error = true;
                        return false;
index 522dade9214afb3490c9c583cfc19da838c3a682..8df4672c3ee16e7eadbfe6017b43cd21d0656897 100644 (file)
@@ -122,6 +122,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                }
 
                current_symbol = root_symbol;
+               context.root.check (this);
                context.accept (this);
        }
 
@@ -130,63 +131,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
 
                next_lambda_id = 0;
 
-               file.accept_children (this);
-       }
-
-       public override void visit_namespace (Namespace ns) {
-               ns.check (this);
-       }
-
-       public override void visit_class (Class cl) {
-               cl.check (this);
-       }
-
-       public override void visit_struct (Struct st) {
-               st.check (this);
-       }
-
-       public override void visit_interface (Interface iface) {
-               iface.check (this);
-       }
-
-       public override void visit_enum (Enum en) {
-               en.check (this);
-       }
-
-       public override void visit_enum_value (EnumValue ev) {
-               ev.check (this);
-       }
-
-       public override void visit_error_domain (ErrorDomain ed) {
-               ed.check (this);
-       }
-
-       public override void visit_error_code (ErrorCode ec) {
-               ec.check (this);
-       }
-
-       public override void visit_delegate (Delegate d) {
-               d.check (this);
-       }
-
-       public override void visit_constant (Constant c) {
-               c.check (this);
-       }
-
-       public override void visit_field (Field f) {
-               f.check (this);
-       }
-
-       public override void visit_method (Method m) {
-               m.check (this);
-       }
-
-       public override void visit_creation_method (CreationMethod m) {
-               m.check (this);
-       }
-
-       public override void visit_formal_parameter (FormalParameter p) {
-               p.check (this);
+               file.check (this);
        }
 
        // check whether type is at least as accessible as the specified symbol
@@ -203,126 +148,6 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                return true;
        }
 
-       public override void visit_property (Property prop) {
-               prop.check (this);
-       }
-
-       public override void visit_property_accessor (PropertyAccessor acc) {
-               acc.check (this);
-       }
-
-       public override void visit_signal (Signal sig) {
-               sig.check (this);
-       }
-
-       public override void visit_constructor (Constructor c) {
-               c.check (this);
-       }
-
-       public override void visit_destructor (Destructor d) {
-               d.check (this);
-       }
-
-       public override void visit_block (Block b) {
-               b.check (this);
-       }
-
-       public override void visit_declaration_statement (DeclarationStatement stmt) {
-               stmt.check (this);
-       }
-
-       public override void visit_local_variable (LocalVariable local) {
-               local.check (this);
-       }
-
-       public override void visit_initializer_list (InitializerList list) {
-               list.check (this);
-       }
-
-       public override void visit_expression_statement (ExpressionStatement stmt) {
-               stmt.check (this);
-       }
-
-       public override void visit_if_statement (IfStatement stmt) {
-               stmt.check (this);
-       }
-
-       public override void visit_switch_section (SwitchSection section) {
-               section.check (this);
-       }
-
-       public override void visit_while_statement (WhileStatement stmt) {
-               stmt.check (this);
-       }
-
-       public override void visit_do_statement (DoStatement stmt) {
-               stmt.check (this);
-       }
-
-       public override void visit_for_statement (ForStatement stmt) {
-               stmt.check (this);
-       }
-
-       public override void visit_foreach_statement (ForeachStatement stmt) {
-               stmt.check (this);
-       }
-
-       public override void visit_return_statement (ReturnStatement stmt) {
-               stmt.check (this);
-       }
-
-       public override void visit_yield_statement (YieldStatement stmt) {
-               stmt.check (this);
-       }
-
-       public override void visit_throw_statement (ThrowStatement stmt) {
-               stmt.check (this);
-       }
-
-       public override void visit_try_statement (TryStatement stmt) {
-               stmt.check (this);
-       }
-
-       public override void visit_catch_clause (CatchClause clause) {
-               clause.check (this);
-       }
-
-       public override void visit_lock_statement (LockStatement stmt) {
-               stmt.check (this);
-       }
-
-       public override void visit_delete_statement (DeleteStatement stmt) {
-               stmt.check (this);
-       }
-
-       public override void visit_array_creation_expression (ArrayCreationExpression expr) {
-               expr.check (this);
-       }
-
-       public override void visit_boolean_literal (BooleanLiteral expr) {
-               expr.check (this);
-       }
-
-       public override void visit_character_literal (CharacterLiteral expr) {
-               expr.check (this);
-       }
-
-       public override void visit_integer_literal (IntegerLiteral expr) {
-               expr.check (this);
-       }
-
-       public override void visit_real_literal (RealLiteral expr) {
-               expr.check (this);
-       }
-
-       public override void visit_string_literal (StringLiteral expr) {
-               expr.check (this);
-       }
-
-       public override void visit_null_literal (NullLiteral expr) {
-               expr.check (this);
-       }
-
        public DataType? get_value_type_for_symbol (Symbol sym, bool lvalue) {
                if (sym is Field) {
                        var f = (Field) sym;
@@ -420,14 +245,6 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                return null;
        }
 
-       public override void visit_parenthesized_expression (ParenthesizedExpression expr) {
-               expr.check (this);
-       }
-       
-       public override void visit_member_access (MemberAccess expr) {
-               expr.check (this);
-       }
-
        public static DataType get_data_type_for_symbol (TypeSymbol sym) {
                DataType type = null;
 
@@ -449,10 +266,6 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                return type;
        }
 
-       public override void visit_invocation_expression (InvocationExpression expr) {
-               expr.check (this);
-       }
-
        public bool check_arguments (Expression expr, DataType mtype, Gee.List<FormalParameter> params, Gee.List<Expression> args) {
                Expression prev_arg = null;
                Iterator<Expression> arg_it = args.iterator ();
@@ -750,10 +563,6 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                return actual_type;
        }
 
-       public override void visit_element_access (ElementAccess expr) {
-               expr.check (this);
-       }
-
        public bool is_in_instance_method () {
                var sym = current_symbol;
                while (sym != null) {
@@ -776,20 +585,8 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                return false;
        }
 
-       public override void visit_base_access (BaseAccess expr) {
-               expr.check (this);
-       }
-
-       public override void visit_postfix_expression (PostfixExpression expr) {
-               expr.check (this);
-       }
-
-       public override void visit_object_creation_expression (ObjectCreationExpression expr) {
-               expr.check (this);
-       }
-
        public void visit_member_initializer (MemberInitializer init, DataType type) {
-               init.accept (this);
+               init.check (this);
 
                init.symbol_reference = symbol_lookup_inherited (type.data_type, init.name);
                if (!(init.symbol_reference is Field || init.symbol_reference is Property)) {
@@ -822,34 +619,6 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                }
        }
 
-       public override void visit_sizeof_expression (SizeofExpression expr) {
-               expr.check (this);
-       }
-
-       public override void visit_typeof_expression (TypeofExpression expr) {
-               expr.check (this);
-       }
-
-       public override void visit_unary_expression (UnaryExpression expr) {
-               expr.check (this);
-       }
-
-       public override void visit_cast_expression (CastExpression expr) {
-               expr.check (this);
-       }
-
-       public override void visit_pointer_indirection (PointerIndirection expr) {
-               expr.check (this);
-       }
-
-       public override void visit_addressof_expression (AddressofExpression expr) {
-               expr.check (this);
-       }
-
-       public override void visit_reference_transfer_expression (ReferenceTransferExpression expr) {
-               expr.check (this);
-       }
-
        public DataType? get_arithmetic_result_type (DataType left_type, DataType right_type) {
                 if (!(left_type.data_type is Struct) || !(right_type.data_type is Struct)) {
                        // at least one operand not struct
@@ -882,18 +651,6 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                 }
        }
 
-       public override void visit_binary_expression (BinaryExpression expr) {
-               expr.check (this);
-       }
-
-       public override void visit_type_check (TypeCheck expr) {
-               expr.check (this);
-       }
-
-       public override void visit_conditional_expression (ConditionalExpression expr) {
-               expr.check (this);
-       }
-
        public Method? find_current_method () {
                var sym = current_symbol;
                while (sym != null) {
@@ -915,12 +672,4 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                }
                return false;
        }
-
-       public override void visit_lambda_expression (LambdaExpression l) {
-               l.check (this);
-       }
-
-       public override void visit_assignment (Assignment a) {
-               a.check (this);
-       }
 }
index fe18b006565f33ef5ff6ad2a78e855c6d8e66e88..3eec703c1367d6d8ec2afcb66464e5ce1db97227 100644 (file)
@@ -228,7 +228,11 @@ public class Vala.Signal : Member, Lockable {
 
                process_attributes ();
 
-               accept_children (analyzer);
+               return_type.check (analyzer);
+               
+               foreach (FormalParameter param in parameters) {
+                       param.check (analyzer);
+               }
 
                return !error;
        }
index d558f100c70fc8c1f4577ce606e473e8051d279c..673b16e9cef3943bfc97590829afd3997136c472 100644 (file)
@@ -76,6 +76,8 @@ public class Vala.SizeofExpression : Expression {
 
                checked = true;
 
+               type_reference.check (analyzer);
+
                value_type = analyzer.ulong_type;
 
                return !error;
index 89a08e1980a42d0d8288a8a459456ed1bb25c667..085372cbe6908c28e8d3900a3247141b8f0da9a5 100644 (file)
@@ -487,6 +487,13 @@ public class Vala.SourceFile {
 
                return mapped_file.get_length ();
        }
+
+       public bool check (SemanticAnalyzer analyzer) {
+               foreach (CodeNode node in nodes) {
+                       node.check (analyzer);
+               }
+               return true;
+       }
 }
 
 public enum Vala.SourceFileDependencyType {
index 4b2c208d656c5e02558149540ffe6a1dd0f0c56a..7efc9500ed09b81b7f3c16c20a77c950dd9ff041 100644 (file)
@@ -625,7 +625,25 @@ public class Vala.Struct : TypeSymbol {
                analyzer.current_symbol = this;
                analyzer.current_struct = this;
 
-               accept_children (analyzer);
+               foreach (DataType type in base_types) {
+                       type.check (analyzer);
+               }
+
+               foreach (TypeParameter p in type_parameters) {
+                       p.check (analyzer);
+               }
+               
+               foreach (Field f in fields) {
+                       f.check (analyzer);
+               }
+               
+               foreach (Constant c in constants) {
+                       c.check (analyzer);
+               }
+               
+               foreach (Method m in methods) {
+                       m.check (analyzer);
+               }
 
                if (!external && !external_package && get_base_types ().size == 0 && get_fields ().size == 0) {
                        Report.error (source_reference, "structs cannot be empty");
index a8ef910368b4b53a4fcdfaf359c89d8553e8663e..34f2ae6778e83dcdc1f1dfc0cc7edb6fceae592e 100644 (file)
@@ -62,4 +62,12 @@ public class Vala.SwitchLabel : CodeNode {
 
                visitor.visit_switch_label (this);
        }
+       
+       public override bool check (SemanticAnalyzer analyzer) {
+               if (expression != null) {
+                       expression.check (analyzer);
+               }
+
+               return true;
+       }
 }
index 2f38944ebbab0990bab4f22d3f649aeba7825657..89137a09f9f243b7a955884536e75fd8f71d4052 100644 (file)
@@ -89,14 +89,14 @@ public class Vala.SwitchSection : Block {
                checked = true;
 
                foreach (SwitchLabel label in get_labels ()) {
-                       label.accept (analyzer);
+                       label.check (analyzer);
                }
 
                owner = analyzer.current_symbol.scope;
                analyzer.current_symbol = this;
 
                foreach (Statement st in get_statements ()) {
-                       st.accept (analyzer);
+                       st.check (analyzer);
                }
 
                foreach (LocalVariable local in get_local_variables ()) {
index e8da2bf164a90165a8413d96241e3091c507aa46..559c94259772ff78cd2314eb5ea7786a60da5653 100644 (file)
@@ -91,4 +91,20 @@ public class Vala.SwitchStatement : CodeNode, Statement {
                        expression = new_node;
                }
        }
+       
+       public override bool check (SemanticAnalyzer analyzer) {
+               if (checked) {
+                       return !error;
+               }
+
+               checked = true;
+
+               expression.check (analyzer);
+
+               foreach (SwitchSection section in sections) {
+                       section.check (analyzer);
+               }
+
+               return !error;
+       }
 }
index d1f8a9f0d84154744cffc9d38276153953639238..3f27778db14b9c7c91c866278801a8c3e63b9927 100644 (file)
@@ -83,7 +83,9 @@ public class Vala.ThrowStatement : CodeNode, Statement {
                error_expression.target_type = new ErrorType (null, null, source_reference);
                error_expression.target_type.value_owned = true;
 
-               accept_children (analyzer);
+               if (error_expression != null) {
+                       error_expression.check (analyzer);
+               }
 
                var error_type = error_expression.value_type.copy ();
                error_type.source_reference = source_reference;
index 456724d606381d5545e5298d367dbfd184c70f6e..fd43dde5ff628a30d803e97fe7e4277ab511dd74 100644 (file)
@@ -94,7 +94,15 @@ public class Vala.TryStatement : CodeNode, Statement {
 
                checked = true;
 
-               accept_children (analyzer);
+               body.check (analyzer);
+
+               foreach (CatchClause clause in catch_clauses) {
+                       clause.check (analyzer);
+               }
+
+               if (finally_body != null) {
+                       finally_body.check (analyzer);
+               }
 
                return !error;
        }
index 4c2436252c6c119e8de218d3454cfd479db6ea04..2dee142f174a086a9c4134d6beb2270864b8c2a5 100644 (file)
@@ -85,6 +85,10 @@ public class Vala.TypeCheck : Expression {
 
                checked = true;
 
+               expression.check (analyzer);
+               
+               type_reference.check (analyzer);
+
                if (type_reference.data_type == null) {
                        /* if type resolving didn't succeed, skip this check */
                        error = true;
index 918ae6ccd4bc238e2feb056715168471e14847d2..b3655985298b57ed3238c3a20cc401be0b87c4a0 100644 (file)
@@ -76,6 +76,8 @@ public class Vala.TypeofExpression : Expression {
 
                checked = true;
 
+               type_reference.check (analyzer);
+
                value_type = analyzer.type_type;
 
                return !error;
index aea2a15787412eec99196de14b886d2cc4946bba..3ddd3467835de034cc43a6395d33f74cf53b15cf 100644 (file)
@@ -148,9 +148,7 @@ public class Vala.UnaryExpression : Expression {
                        inner.target_type = target_type;
                }
 
-               accept_children (analyzer);
-
-               if (inner.error) {
+               if (!inner.check (analyzer)) {
                        /* if there was an error in the inner expression, skip type check */
                        error = true;
                        return false;
@@ -207,7 +205,7 @@ public class Vala.UnaryExpression : Expression {
                        parenthexp.target_type = target_type;
                        analyzer.replaced_nodes.add (this);
                        parent_node.replace_expression (this, parenthexp);
-                       parenthexp.accept (analyzer);
+                       parenthexp.check (analyzer);
                        return true;
                } else if (operator == UnaryOperator.REF || operator == UnaryOperator.OUT) {
                        if (inner.symbol_reference is Field || inner.symbol_reference is FormalParameter || inner.symbol_reference is LocalVariable) {
index ee3a43c67e7180ed3c811a0168532a486d31a303..028538c0d01f7885223b37bc1ab6003f14f7b001 100644 (file)
@@ -94,7 +94,9 @@ public class Vala.WhileStatement : CodeNode, Statement {
 
                checked = true;
 
-               accept_children (analyzer);
+               condition.check (analyzer);
+               
+               body.check (analyzer);
 
                if (condition.error) {
                        /* if there was an error in the condition, skip this check */
index 2c1b06bb7dcbb38d472dca4d133b766490451059..ca4d0d6fb159e858625936d883d4213be37aaf20 100644 (file)
@@ -71,7 +71,7 @@ public class Vala.YieldStatement : CodeNode, Statement {
 
        public override bool check (SemanticAnalyzer analyzer) {
                if (yield_expression != null) {
-                       yield_expression.accept (analyzer);
+                       yield_expression.check (analyzer);
                        error = yield_expression.error;
                }