From a78be0ff8dd9de24a173dc1bce3d0c3c07a3cf80 Mon Sep 17 00:00:00 2001 From: Juerg Billeter Date: Tue, 12 Feb 2008 18:00:47 +0000 Subject: [PATCH] fix crash when using prefix increment in element access expression, fixes 2008-02-12 Juerg Billeter * vala/valaelementaccess.vala: fix crash when using prefix increment in element access expression, fixes bug 515733 svn path=/trunk/; revision=1006 --- ChangeLog | 5 +++++ vala/valaelementaccess.vala | 19 ++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index bca8f25..977b7d9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2008-02-12 Jürg Billeter + * vala/valaelementaccess.vala: fix crash when using prefix + increment in element access expression, fixes bug 515733 + +2008-02-12 Jürg Billeter + * gobject/valaccodegenerator.vala: fix using instance methods as delegates in the constructor diff --git a/vala/valaelementaccess.vala b/vala/valaelementaccess.vala index 9b99727..d118a0b 100644 --- a/vala/valaelementaccess.vala +++ b/vala/valaelementaccess.vala @@ -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! indices = new ArrayList (); - + public void append_index (Expression! index) { indices.add (index); + index.parent_node = this; } - + public Gee.List get_indices () { return new ReadOnlyList (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 ()) { -- 2.7.4