[vala/0.40] vala: Add missing replace_expression() implementations



commit 22390ff29687ae94145a177326f2d41028c7ba46
Author: Luca Bruno <lucabru src gnome org>
Date:   Thu Dec 29 12:39:15 2011 +0100

    vala: Add missing replace_expression() implementations

 vala/valaconditionalexpression.vala | 12 ++++++++++++
 vala/valadeletestatement.vala       |  6 ++++++
 vala/valadostatement.vala           |  6 ++++++
 vala/valaforstatement.vala          | 16 ++++++++++++++++
 vala/valalockstatement.vala         |  6 ++++++
 vala/valapostfixexpression.vala     |  6 ++++++
 vala/valatemplate.vala              |  8 ++++++++
 vala/valaunlockstatement.vala       |  6 ++++++
 vala/valawhilestatement.vala        |  6 ++++++
 9 files changed, 72 insertions(+)
---
diff --git a/vala/valaconditionalexpression.vala b/vala/valaconditionalexpression.vala
index daf8b7a9e..d64cde75e 100644
--- a/vala/valaconditionalexpression.vala
+++ b/vala/valaconditionalexpression.vala
@@ -104,6 +104,18 @@ public class Vala.ConditionalExpression : Expression {
                return condition.is_accessible (sym) && true_expression.is_accessible (sym) && 
false_expression.is_accessible (sym);
        }
 
+       public override void replace_expression (Expression old_node, Expression new_node) {
+               if (condition == old_node) {
+                       condition = new_node;
+               }
+               if (true_expression == old_node) {
+                       true_expression = new_node;
+               }
+               if (false_expression == old_node) {
+                       false_expression = new_node;
+               }
+       }
+
        public override bool check (CodeContext context) {
                if (checked) {
                        return !error;
diff --git a/vala/valadeletestatement.vala b/vala/valadeletestatement.vala
index e12b5c4e1..ff3ff6891 100644
--- a/vala/valadeletestatement.vala
+++ b/vala/valadeletestatement.vala
@@ -50,6 +50,12 @@ public class Vala.DeleteStatement : CodeNode, Statement {
                expression.accept (visitor);
        }
 
+       public override void replace_expression (Expression old_node, Expression new_node) {
+               if (expression == old_node) {
+                       expression = new_node;
+               }
+       }
+
        public override bool check (CodeContext context) {
                if (checked) {
                        return !error;
diff --git a/vala/valadostatement.vala b/vala/valadostatement.vala
index c368b5b28..68e6e9320 100644
--- a/vala/valadostatement.vala
+++ b/vala/valadostatement.vala
@@ -86,6 +86,12 @@ public class Vala.DoStatement : CodeNode, Statement {
                return (literal != null && literal.value);
        }
 
+       public override void replace_expression (Expression old_node, Expression new_node) {
+               if (condition == old_node) {
+                       condition = new_node;
+               }
+       }
+
        public override bool check (CodeContext context) {
                // convert to simple loop
 
diff --git a/vala/valaforstatement.vala b/vala/valaforstatement.vala
index ab80af520..0950d6f7a 100644
--- a/vala/valaforstatement.vala
+++ b/vala/valaforstatement.vala
@@ -136,6 +136,22 @@ public class Vala.ForStatement : CodeNode, Statement {
                body.accept (visitor);
        }
 
+       public override void replace_expression (Expression old_node, Expression new_node) {
+               if (condition == old_node) {
+                       condition = new_node;
+               }
+               for (int i=0; i < initializer.size; i++) {
+                       if (initializer[i] == old_node) {
+                               initializer[i] = new_node;
+                       }
+               }
+               for (int i=0; i < iterator.size; i++) {
+                       if (iterator[i] == old_node) {
+                               iterator[i] = new_node;
+                       }
+               }
+       }
+
        bool always_true (Expression condition) {
                var literal = condition as BooleanLiteral;
                return (literal != null && literal.value);
diff --git a/vala/valalockstatement.vala b/vala/valalockstatement.vala
index e0d4216f9..358fb3cf9 100644
--- a/vala/valalockstatement.vala
+++ b/vala/valalockstatement.vala
@@ -57,6 +57,12 @@ public class Vala.LockStatement : CodeNode, Statement {
                visitor.visit_lock_statement (this);
        }
 
+       public override void replace_expression (Expression old_node, Expression new_node) {
+               if (resource == old_node) {
+                       resource = new_node;
+               }
+       }
+
        public override bool check (CodeContext context) {
                if (body != null) {
                        // if the statement isn't empty, it is converted into a try statement
diff --git a/vala/valapostfixexpression.vala b/vala/valapostfixexpression.vala
index 05274c1e9..dd6e35194 100644
--- a/vala/valapostfixexpression.vala
+++ b/vala/valapostfixexpression.vala
@@ -91,6 +91,12 @@ public class Vala.PostfixExpression : Expression {
                inner.get_used_variables (collection);
        }
 
+       public override void replace_expression (Expression old_node, Expression new_node) {
+               if (inner == old_node) {
+                       inner = new_node;
+               }
+       }
+
        public override bool check (CodeContext context) {
                if (checked) {
                        return !error;
diff --git a/vala/valatemplate.vala b/vala/valatemplate.vala
index 5e27a7b8e..dd66c3d4c 100644
--- a/vala/valatemplate.vala
+++ b/vala/valatemplate.vala
@@ -58,6 +58,14 @@ public class Vala.Template : Expression {
                }
        }
 
+       public override void replace_expression (Expression old_node, Expression new_node) {
+               int index = expression_list.index_of (old_node);
+               if (index >= 0) {
+                       expression_list[index] = new_node;
+                       new_node.parent_node = this;
+               }
+       }
+
        public override bool check (CodeContext context) {
                if (checked) {
                        return !error;
diff --git a/vala/valaunlockstatement.vala b/vala/valaunlockstatement.vala
index ff2f40185..6449f8e0f 100644
--- a/vala/valaunlockstatement.vala
+++ b/vala/valaunlockstatement.vala
@@ -40,6 +40,12 @@ public class Vala.UnlockStatement : CodeNode, Statement {
                visitor.visit_unlock_statement (this);
        }
 
+       public override void replace_expression (Expression old_node, Expression new_node) {
+               if (resource == old_node) {
+                       resource = new_node;
+               }
+       }
+
        public override bool check (CodeContext context) {
                if (checked) {
                        return !error;
diff --git a/vala/valawhilestatement.vala b/vala/valawhilestatement.vala
index 6a1bcde13..bec6b35b3 100644
--- a/vala/valawhilestatement.vala
+++ b/vala/valawhilestatement.vala
@@ -91,6 +91,12 @@ public class Vala.WhileStatement : CodeNode, Statement {
                return (literal != null && !literal.value);
        }
 
+       public override void replace_expression (Expression old_node, Expression new_node) {
+               if (condition == old_node) {
+                       condition = new_node;
+               }
+       }
+
        public override bool check (CodeContext context) {
                // convert to simple loop
 


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