Commit ff19fcfc authored by Raffaele Sandrini's avatar Raffaele Sandrini Committed by Raffaele Sandrini
Browse files

assign parent_node to children of this statement; include iterator and

2007-03-24  Raffaele Sandrini  <rasa@gmx.ch>

	* vala/valaforstatement.vala: assign parent_node to children of this
	  statement; include iterator and initializer in replacement of a child
	  node (fixes segfault using prefix increment expression in the
	  iterator of a for-statement)

svn path=/trunk/; revision=266
parent bb562fba
2007-03-24 Raffaele Sandrini <rasa@gmx.ch>
* vala/valaforstatement.vala: assign parent_node to children of this
statement; include iterator and initializer in replacement of a child
node (fixes segfault using prefix increment expression in the
iterator of a for-statement)
2007-03-22 Raffaele Sandrini <rasa@gmx.ch>
* vala/valaflags.vala, vala/valaenum.vala, vala/valadatatype.vala,
vala/valastruct.vala: add support for default values of types
* vala/valacodegenerator.vala: use default values for initialization
......
......@@ -69,6 +69,7 @@ public class Vala.ForStatement : Statement {
* @param init an initializer expression
*/
public void add_initializer (Expression! init) {
init.parent_node = this;
initializer.append (init);
}
......@@ -87,6 +88,7 @@ public class Vala.ForStatement : Statement {
* @param iter an iterator expression
*/
public void add_iterator (Expression! iter) {
iter.parent_node = this;
iterator.append (iter);
}
......@@ -118,8 +120,29 @@ public class Vala.ForStatement : Statement {
}
public override void replace (CodeNode! old_node, CodeNode! new_node) {
weak List<Expression> iter;
if (condition == old_node) {
condition = (Expression) new_node;
return;
}
for (iter = initializer; iter != null; iter = iter.next) {
if (iter.data == old_node) {
weak List<Expression> silbling = iter.next;
initializer.delete_link (iter);
initializer.insert_before (silbling, new_node);
return;
}
}
for (iter = iterator; iter != null; iter = iter.next) {
if (iter.data == old_node) {
weak List<Expression> silbling = iter.next;
iterator.delete_link (iter);
iterator.insert_before (silbling, new_node);
return;
}
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment