Skip to content
Snippets Groups Projects
Commit 6f548048ac94 authored by Sylvain Thenault's avatar Sylvain Thenault
Browse files

new undefine argument telling if variable with no more references should be...

new undefine argument telling if variable with no more references should be removed (False by default for consistency with old behaviour)
parent aab42b53c0aa
No related branches found
No related tags found
No related merge requests found
......@@ -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))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment