fix crash when using prefix increment in element access expression, fixes
authorJuerg Billeter <j@bitron.ch>
Tue, 12 Feb 2008 18:00:47 +0000 (18:00 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Tue, 12 Feb 2008 18:00:47 +0000 (18:00 +0000)
2008-02-12  Juerg Billeter  <j@bitron.ch>

* vala/valaelementaccess.vala: fix crash when using prefix
  increment in element access expression, fixes bug 515733

svn path=/trunk/; revision=1006

ChangeLog
vala/valaelementaccess.vala

index bca8f25..977b7d9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2008-02-12  Jürg Billeter  <j@bitron.ch>
 
+       * vala/valaelementaccess.vala: fix crash when using prefix
+         increment in element access expression, fixes bug 515733
+
+2008-02-12  Jürg Billeter  <j@bitron.ch>
+
        * gobject/valaccodegenerator.vala: fix using instance methods as
          delegates in the constructor
 
index 9b99727..d118a0b 100644 (file)
@@ -1,6 +1,6 @@
 /* valaelementaccess.vala
  *
- * Copyright (C) 2006-2007  Raffaele Sandrini, Jürg Billeter
+ * Copyright (C) 2006-2008  Raffaele Sandrini, Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -37,11 +37,12 @@ public class Vala.ElementAccess : Expression {
         * Expressions representing the indices we want to access inside the container.
         */
        private Gee.List<Expression>! indices = new ArrayList<Expression> ();
-       
+
        public void append_index (Expression! index) {
                indices.add (index);
+               index.parent_node = this;
        }
-       
+
        public Gee.List<Expression> get_indices () {
                return new ReadOnlyList<Expression> (indices);
        }
@@ -58,6 +59,18 @@ public class Vala.ElementAccess : Expression {
                visitor.visit_element_access (this);
        }
 
+       public override void replace_expression (Expression! old_node, Expression! new_node) {
+               if (container == old_node) {
+                       container = new_node;
+               }
+               
+               int index = indices.index_of (old_node);
+               if (index >= 0 && new_node.parent_node == null) {
+                       indices[index] = new_node;
+                       new_node.parent_node = this;
+               }
+       }
+
        public override bool is_pure () {
                foreach (Expression index in indices) {
                        if (!index.is_pure ()) {