[vala/wip/transform: 71/98] Set parent_node when replacing expressions



commit 550c90c2e6618dc2dc627c33ca937f387683f87b
Author: Luca Bruno <lucabru src gnome org>
Date:   Mon Oct 29 21:04:18 2012 +0100

    Set parent_node when replacing expressions

 tests/structs/structs.vala            |   16 ++++++++++++++++
 vala/valaarraycreationexpression.vala |    1 +
 vala/valaforstatement.vala            |    2 ++
 vala/valainitializerlist.vala         |    1 +
 vala/valatuple.vala                   |    1 +
 5 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/tests/structs/structs.vala b/tests/structs/structs.vala
index 543975a..90ef408 100644
--- a/tests/structs/structs.vala
+++ b/tests/structs/structs.vala
@@ -34,6 +34,16 @@ struct StructWithNamedCreationMethod {
        public int field;
 }
 
+
+delegate void Func ();
+
+struct StructWithFunc {
+       int foo;
+
+       public StructWithFunc (Func f) {
+       }
+}
+
 void test_in_parameter (SimpleStruct st) {
        stdout.printf ("test_in_parameter: st.field = %d\n", st.field);
 }
@@ -53,6 +63,12 @@ void test_out_parameter (out SimpleStruct st) {
        st.field = 3;
 }
 
+void test_struct_with_func () {
+       var foes = new StructWithFunc[] {
+               StructWithFunc (() => {})
+       };
+}
+
 void main () {
        stdout.printf ("Structs Test:\n");
 
diff --git a/vala/valaarraycreationexpression.vala b/vala/valaarraycreationexpression.vala
index 43135b3..6d71ea6 100644
--- a/vala/valaarraycreationexpression.vala
+++ b/vala/valaarraycreationexpression.vala
@@ -135,6 +135,7 @@ public class Vala.ArrayCreationExpression : Expression {
                for (int i = 0; i < sizes.size; i++) {
                        if (sizes[i] == old_node) {
                                sizes[i] = new_node;
+                               new_node.parent_node = this;
                                return;
                        }
                }
diff --git a/vala/valaforstatement.vala b/vala/valaforstatement.vala
index c79a6d1..8c91219 100644
--- a/vala/valaforstatement.vala
+++ b/vala/valaforstatement.vala
@@ -143,11 +143,13 @@ public class Vala.ForStatement : BaseStatement {
                for (int i=0; i < initializer.size; i++) {
                        if (initializer[i] == old_node) {
                                initializer[i] = new_node;
+                               new_node.parent_node = this;
                        }
                }
                for (int i=0; i < iterator.size; i++) {
                        if (iterator[i] == old_node) {
                                iterator[i] = new_node;
+                               new_node.parent_node = this;
                        }
                }
        }
diff --git a/vala/valainitializerlist.vala b/vala/valainitializerlist.vala
index 6108946..bd57bcc 100644
--- a/vala/valainitializerlist.vala
+++ b/vala/valainitializerlist.vala
@@ -114,6 +114,7 @@ public class Vala.InitializerList : Expression {
                for (int i = 0; i < initializers.size; i++) {
                        if (initializers[i] == old_node) {
                                initializers[i] = new_node;
+                               new_node.parent_node = this;
                        }
                }
        }
diff --git a/vala/valatuple.vala b/vala/valatuple.vala
index d35795a..f813138 100644
--- a/vala/valatuple.vala
+++ b/vala/valatuple.vala
@@ -60,6 +60,7 @@ public class Vala.Tuple : Expression {
                for (int i = 0; i < expression_list.size; i++) {
                        if (expression_list[i] == old_node) {
                                expression_list[i] = new_node;
+                               new_node.parent_node = this;
                        }
                }
        }


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