# HG changeset patch # User Sylvain Thenault <sylvain.thenault@logilab.fr> # Date 1223992967 -7200 # Tue Oct 14 16:02:47 2008 +0200 # Node ID 6f548048ac94ae85eeac95e3c1e783c4b6870488 # Parent aab42b53c0aa11e49bb02afe32afa097baa3bf49 new undefine argument telling if variable with no more references should be removed (False by default for consistency with old behaviour) diff --git a/nodes.py b/nodes.py --- a/nodes.py +++ b/nodes.py @@ -103,7 +103,7 @@ # root is None during parsing return root is not None and root.should_register_op - def remove_node(self, node): + def remove_node(self, node, undefine=False): """remove the given node from the tree USE THIS METHOD INSTEAD OF .remove to get correct variable references @@ -112,8 +112,8 @@ # unregister variable references in the removed subtree for varref in node.iget_nodes(VariableRef): varref.unregister_reference() - #if not varref.variable.references(): - # node.root.undefine_variable(varref.variable) + if undefine and not varref.variable.stinfo['references']: + node.stmt.undefine_variable(varref.variable) if self.should_register_op: from rql.undo import RemoveNodeOperation self.undo_manager.add_operation(RemoveNodeOperation(node))