[vala/wip/transform: 81/179] Analyze nodes after they are inserted into the tree



commit f7a825fa7d4cfa46ac877342137ac822ef4567be
Author: Luca Bruno <lucabru src gnome org>
Date:   Fri Aug 5 17:22:18 2011 +0200

    Analyze nodes after they are inserted into the tree

 vala/valabinaryexpression.vala         |   25 ++++++++++++++-----------
 vala/valaconditionalexpression.vala    |    8 ++++----
 vala/valamethodcall.vala               |    1 -
 vala/valaobjectcreationexpression.vala |    1 -
 4 files changed, 18 insertions(+), 17 deletions(-)
---
diff --git a/vala/valabinaryexpression.vala b/vala/valabinaryexpression.vala
index 6fac539..3557173 100644
--- a/vala/valabinaryexpression.vala
+++ b/vala/valabinaryexpression.vala
@@ -31,7 +31,7 @@ public class Vala.BinaryExpression : Expression {
         * The binary operator.
         */
        public BinaryOperator operator { get; set; }
-
+       
        /**
         * The left operand.
         */
@@ -44,7 +44,7 @@ public class Vala.BinaryExpression : Expression {
                        _left.parent_node = this;
                }
        }
-
+       
        /**
         * The right operand.
         */
@@ -57,12 +57,12 @@ public class Vala.BinaryExpression : Expression {
                        _right.parent_node = this;
                }
        }
-
+       
        public bool is_chained { get; private set; }
 
        private Expression _left;
        private Expression _right;
-
+       
        /**
         * Creates a new binary expression.
         *
@@ -96,7 +96,7 @@ public class Vala.BinaryExpression : Expression {
 
        public override void accept_children (CodeVisitor visitor) {
                left.accept (visitor);
-               right.accept (visitor);
+               right.accept (visitor);                 
        }
 
        public override void replace_expression (Expression old_node, Expression new_node) {
@@ -170,7 +170,6 @@ public class Vala.BinaryExpression : Expression {
 
                        var local = new LocalVariable (context.analyzer.bool_type.copy (), get_temp_name (), 
null, source_reference);
                        var decl = new DeclarationStatement (local, source_reference);
-                       decl.check (context);
 
                        var right_stmt = new ExpressionStatement (new Assignment (new MemberAccess.simple 
(local.name, right.source_reference), right, AssignmentOperator.SIMPLE, right.source_reference), 
right.source_reference);
 
@@ -192,6 +191,8 @@ public class Vala.BinaryExpression : Expression {
                        insert_statement (context.analyzer.insert_block, decl);
                        insert_statement (context.analyzer.insert_block, if_stmt);
 
+                       decl.check (context);
+
                        if (!if_stmt.check (context)) {
                                error = true;
                                return false;
@@ -200,10 +201,11 @@ public class Vala.BinaryExpression : Expression {
                        var ma = new MemberAccess.simple (local.name, source_reference);
                        ma.target_type = target_type;
                        ma.formal_target_type = formal_target_type;
-                       ma.check (context);
 
                        parent_node.replace_expression (this, ma);
 
+                       ma.check (context);
+
                        return true;
                }
 
@@ -247,7 +249,7 @@ public class Vala.BinaryExpression : Expression {
                        } else if (right.value_type != null) {
                                local_type = right.value_type.copy ();
                        }
-
+               
                        var local = new LocalVariable (local_type, get_temp_name (), left, source_reference);
                        var decl = new DeclarationStatement (local, source_reference);
 
@@ -281,10 +283,11 @@ public class Vala.BinaryExpression : Expression {
                                cast.target_type.nullable = false;
                                replace_expr = cast;
                        }
-                       replace_expr.check (context);
 
                        parent_node.replace_expression (this, replace_expr);
 
+                       replace_expr.check (context);
+
                        return true;
                }
 
@@ -539,9 +542,9 @@ public class Vala.BinaryExpression : Expression {
                                parent_node.replace_expression (this, contains_call);
                                return contains_call.check (context);
                        }
-
+                       
                        value_type = context.analyzer.bool_type;
-
+                       
                } else {
                        assert_not_reached ();
                }
diff --git a/vala/valaconditionalexpression.vala b/vala/valaconditionalexpression.vala
index d139cae..daf8b7a 100644
--- a/vala/valaconditionalexpression.vala
+++ b/vala/valaconditionalexpression.vala
@@ -83,7 +83,7 @@ public class Vala.ConditionalExpression : Expression {
                false_expression = false_expr;
                source_reference = source;
        }
-
+       
        public override void accept (CodeVisitor visitor) {
                visitor.visit_conditional_expression (this);
 
@@ -173,20 +173,20 @@ public class Vala.ConditionalExpression : Expression {
                false_expression.target_type = value_type;
 
                var true_stmt = new ExpressionStatement (new Assignment (new MemberAccess.simple (local.name, 
true_expression.source_reference), true_expression, AssignmentOperator.SIMPLE, 
true_expression.source_reference), true_expression.source_reference);
-               true_stmt.check (context);
 
                var false_stmt = new ExpressionStatement (new Assignment (new MemberAccess.simple 
(local.name, false_expression.source_reference), false_expression, AssignmentOperator.SIMPLE, 
false_expression.source_reference), false_expression.source_reference);
-               false_stmt.check (context);
 
                true_block.replace_statement (true_decl, true_stmt);
                false_block.replace_statement (false_decl, false_stmt);
+               true_stmt.check (context);
+               false_stmt.check (context);
 
                var ma = new MemberAccess.simple (local.name, source_reference);
                ma.formal_target_type = formal_target_type;
                ma.target_type = target_type;
-               ma.check (context);
 
                parent_node.replace_expression (this, ma);
+               ma.check (context);
 
                return true;
        }
diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala
index cc6a3fc..62d51dd 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -645,7 +645,6 @@ public class Vala.MethodCall : Expression {
                                local.initializer = this;
                                decl.check (context);
 
-
                                // move temp variable to insert block to ensure the
                                // variable is in the same block as the declaration
                                // otherwise there will be scoping issues in the generated code
diff --git a/vala/valaobjectcreationexpression.vala b/vala/valaobjectcreationexpression.vala
index 08a37df..d3b01c2 100644
--- a/vala/valaobjectcreationexpression.vala
+++ b/vala/valaobjectcreationexpression.vala
@@ -504,7 +504,6 @@ public class Vala.ObjectCreationExpression : Expression {
                                local.initializer = this;
                                decl.check (context);
 
-
                                // move temp variable to insert block to ensure the
                                // variable is in the same block as the declaration
                                // otherwise there will be scoping issues in the generated code


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]