]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Fix several AST construction/parenting issues
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 23 Oct 2018 11:40:54 +0000 (13:40 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 23 Oct 2018 16:45:45 +0000 (18:45 +0200)
14 files changed:
vala/valaarraycreationexpression.vala
vala/valaclass.vala
vala/valaelementaccess.vala
vala/valaerrorcode.vala
vala/valaforstatement.vala
vala/valainitializerlist.vala
vala/valalockstatement.vala
vala/valamethodcall.vala
vala/valaobjectcreationexpression.vala
vala/valaswitchlabel.vala
vala/valaswitchsection.vala
vala/valatemplate.vala
vala/valatuple.vala
vala/valaunlockstatement.vala

index 41b0f351b2ca113c8d0a278273a48c0ab0f1cddb..0969ff0e67c54c145740b1f1e4faf3fbc8470981 100644 (file)
@@ -131,6 +131,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;
                        }
                }
index 4f5aa4b874d024d99cb49ab9a9e7f7b98ecfc6c9..def794f1722ab896140f246ba0e1164eb3c63061 100644 (file)
@@ -119,17 +119,41 @@ public class Vala.Class : ObjectTypeSymbol {
        /**
         * Specifies the instance constructor.
         */
-       public Constructor constructor { get; set; }
+       public Constructor constructor {
+               get { return _constructor; }
+               set {
+                       _constructor = value;
+                       if (_constructor != null) {
+                               _constructor.owner = scope;
+                       }
+               }
+       }
 
        /**
         * Specifies the class constructor.
         */
-       public Constructor class_constructor { get; set; }
+       public Constructor class_constructor {
+               get { return _class_constructor; }
+               set {
+                       _class_constructor = value;
+                       if (_class_constructor != null) {
+                               _class_constructor.owner = scope;
+                       }
+               }
+       }
 
        /**
         * Specifies the static class constructor.
         */
-       public Constructor static_constructor { get; set; }
+       public Constructor static_constructor {
+               get { return _static_constructor; }
+               set {
+                       _static_constructor = value;
+                       if (_static_constructor != null) {
+                               _static_constructor.owner = scope;
+                       }
+               }
+       }
 
        /**
         * Specifies the instance destructor.
@@ -139,6 +163,7 @@ public class Vala.Class : ObjectTypeSymbol {
                set {
                        _destructor = value;
                        if (_destructor != null) {
+                               _destructor.owner = scope;
                                if (_destructor.this_parameter != null) {
                                        _destructor.scope.remove (_destructor.this_parameter.name);
                                }
@@ -151,12 +176,28 @@ public class Vala.Class : ObjectTypeSymbol {
        /**
         * Specifies the class destructor.
         */
-       public Destructor? static_destructor { get; set; }
+       public Destructor? static_destructor {
+               get { return _static_destructor; }
+               set {
+                       _static_destructor = value;
+                       if (_static_destructor != null) {
+                               _static_destructor.owner = scope;
+                       }
+               }
+       }
 
        /**
         * Specifies the class destructor.
         */
-       public Destructor? class_destructor { get; set; }
+       public Destructor? class_destructor {
+               get { return _class_destructor; }
+               set {
+                       _class_destructor = value;
+                       if (_class_destructor != null) {
+                               _class_destructor.owner = scope;
+                       }
+               }
+       }
 
        /**
         * Specifies whether this class denotes an error base.
@@ -167,7 +208,12 @@ public class Vala.Class : ObjectTypeSymbol {
                }
        }
 
+       Constructor _constructor;
+       Constructor _class_constructor;
+       Constructor _static_constructor;
        Destructor? _destructor;
+       Destructor? _class_destructor;
+       Destructor? _static_destructor;
 
        /**
         * Creates a new class.
index 88c396ae14bcdd955ed3610683af0c77f71294e5..c7c78349093bdab8e36f94e86d548fbaaf034686 100644 (file)
@@ -81,7 +81,7 @@ public class Vala.ElementAccess : Expression {
                }
 
                int index = indices.index_of (old_node);
-               if (index >= 0 && new_node.parent_node == null) {
+               if (index >= 0) {
                        indices[index] = new_node;
                        new_node.parent_node = this;
                }
index 93308aec24c9d7910f1e12a03155aa3dc5143a0e..ef5f36410cc6235b4213bfacc5c8af6532e1e1e5 100644 (file)
@@ -29,7 +29,17 @@ public class Vala.ErrorCode : TypeSymbol {
        /**
         * Specifies the numerical representation of this enum value.
         */
-       public Expression value { get; set; }
+       public Expression? value {
+               get { return _value; }
+               set {
+                       _value = value;
+                       if (_value != null) {
+                               _value.parent_node = this;
+                       }
+               }
+       }
+
+       private Expression _value;
 
        /**
         * Creates a new enum value.
index 79bd063f74517c961a86b607420d34fdde879c63..bd3229ad55ee8490db5421ae83db392a770fae58 100644 (file)
@@ -143,11 +143,13 @@ public class Vala.ForStatement : CodeNode, Statement {
                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;
                        }
                }
        }
index 8a601874e2365c5ec633f9e060ba2288b5812d57..aba79290fb56755bf14c53a22a70c52ffed1a4a0 100644 (file)
@@ -110,6 +110,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;
                        }
                }
        }
index 65d8ff09e8af7cde1ede6cba683903595e9b1586..7099383faff4e85d0b21a2ecfa28bd3225551158 100644 (file)
@@ -36,12 +36,29 @@ public class Vala.LockStatement : CodeNode, Statement {
        /**
         * Expression representing the resource to be locked.
         */
-       public Expression resource { get; set; }
+       public Expression resource {
+               get { return _resource; }
+               set {
+                       _resource = value;
+                       _resource.parent_node = this;
+               }
+       }
 
        /**
         * The statement during its execution the resource is locked.
         */
-       public Block? body { get; set; }
+       public Block? body {
+               get { return _body; }
+               set {
+                       _body = value;
+                       if (_body != null) {
+                               _body.parent_node = this;
+                       }
+               }
+       }
+
+       private Expression _resource;
+       private Block _body;
 
        public LockStatement (Expression resource, Block? body, SourceReference? source_reference = null) {
                this.body = body;
index 9864abc0ced672e7083b6280afa759c1c20e6c15..86014c2801e9c8e4666dcdba367e0e8b83b9307b 100644 (file)
@@ -103,7 +103,7 @@ public class Vala.MethodCall : Expression {
                }
 
                int index = argument_list.index_of (old_node);
-               if (index >= 0 && new_node.parent_node == null) {
+               if (index >= 0) {
                        argument_list[index] = new_node;
                        new_node.parent_node = this;
                }
index 4b609aee7dc4be4819bb909e36f690de8ba0774b..ff0e818e3daddceedc560a67db6f5dfb41acdee6 100644 (file)
@@ -41,7 +41,15 @@ public class Vala.ObjectCreationExpression : Expression {
         * The construction method to use or the data type to be created
         * with the default construction method.
         */
-       public MemberAccess member_name { get; set; }
+       public MemberAccess? member_name {
+               get { return _member_name; }
+               set {
+                       _member_name = value;
+                       if (_member_name != null) {
+                               _member_name.parent_node = this;
+                       }
+               }
+       }
 
        public bool is_yield_expression { get; set; }
 
@@ -52,6 +60,7 @@ public class Vala.ObjectCreationExpression : Expression {
        private List<MemberInitializer> object_initializer = new ArrayList<MemberInitializer> ();
 
        private DataType _data_type;
+       private MemberAccess? _member_name;
 
        /**
         * Creates a new object creation expression.
@@ -60,7 +69,7 @@ public class Vala.ObjectCreationExpression : Expression {
         * @param source_reference reference to source code
         * @return                 newly created object creation expression
         */
-       public ObjectCreationExpression (MemberAccess member_name, SourceReference source_reference) {
+       public ObjectCreationExpression (MemberAccess? member_name, SourceReference source_reference) {
                this.source_reference = source_reference;
                this.member_name = member_name;
        }
@@ -129,7 +138,7 @@ public class Vala.ObjectCreationExpression : Expression {
 
        public override void replace_expression (Expression old_node, Expression new_node) {
                int index = argument_list.index_of (old_node);
-               if (index >= 0 && new_node.parent_node == null) {
+               if (index >= 0) {
                        argument_list[index] = new_node;
                        new_node.parent_node = this;
                }
index 70eb7e336af1aba03c47fc2d107b76c161790a2a..d3df5a3ee7182b2ffa13fc36e5954566ec34584d 100644 (file)
@@ -29,9 +29,19 @@ public class Vala.SwitchLabel : CodeNode {
        /**
         * Specifies the label expression.
         */
-       public Expression expression { get; set; }
+       public Expression expression {
+               get { return _expression; }
+               set {
+                       _expression = value;
+                       _expression.parent_node = this;
+               }
+       }
+
+       public weak SwitchSection section {
+               get { return (SwitchSection) parent_node; }
+       }
 
-       public weak SwitchSection section { get; set; }
+       private Expression _expression;
 
        /**
         * Creates a new switch case label.
index 2b0da58377a0c55640f71a909f433562bcf20b20..2b6bc60ab73ed9b87ebbc3dc3c6cade939451fad 100644 (file)
@@ -49,7 +49,7 @@ public class Vala.SwitchSection : Block {
                }
 
                labels.add (label);
-               label.section = this;
+               label.parent_node = this;
        }
 
        /**
index dd66c3d4c1e693242280fd9c589b97114b2e9cae..5def6781ba68169a46ffb5f1b0c78121d39db18c 100644 (file)
@@ -40,6 +40,7 @@ public class Vala.Template : Expression {
 
        public void add_expression (Expression expr) {
                expression_list.add (expr);
+               expr.parent_node = this;
        }
 
        public List<Expression> get_expressions () {
index d35795a392a492f946c957f1afeadb58d6dfabd0..87a0a9c4e3df9bb8d36841f1c4b6e61c51745c9d 100644 (file)
@@ -46,6 +46,7 @@ public class Vala.Tuple : Expression {
 
        public void add_expression (Expression expr) {
                expression_list.add (expr);
+               expr.parent_node = this;
        }
 
        public List<Expression> get_expressions () {
@@ -60,6 +61,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;
                        }
                }
        }
index 69f9eb0220fef33f7c852bf05c8780c8df9c68bf..3e49671ee275931c33ecc5c9459ae6f221b49437 100644 (file)
@@ -28,7 +28,15 @@ public class Vala.UnlockStatement : CodeNode, Statement {
        /**
         * Expression representing the resource to be unlocked.
         */
-       public Expression resource { get; set; }
+       public Expression resource {
+               get { return _resource; }
+               set {
+                       _resource = value;
+                       _resource.parent_node = this;
+               }
+       }
+
+       private Expression _resource;
 
        public UnlockStatement (Expression resource, SourceReference? source_reference = null) {
                this.source_reference = source_reference;