Skip to content

Commit

Permalink
unwarper: remove an obsolete functionality for a block splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrian Nord authored and Andrian Nord committed Jan 25, 2014
1 parent fdcf97f commit e0ebe38
Showing 1 changed file with 17 additions and 32 deletions.
49 changes: 17 additions & 32 deletions ljd/ast/unwarper.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,16 @@ def _split_by_slot_use(statements, min_i, warp, slot):
split_i = min_i

for i, statement in enumerate(statements):
sets, _uses = _extract_statement_slots(statement)
if isinstance(statement, nodes.Assignment):
sets = _extract_destination_slots(statement)

if i < min_i:
known_slots |= sets
else:
known_slots -= sets
if i < min_i:
known_slots |= sets
else:
known_slots -= sets

if len(known_slots) == 0:
break
if len(known_slots) == 0:
break

split_i = i + 1

Expand All @@ -262,33 +263,17 @@ def _split_by_slot_use(statements, min_i, warp, slot):
return split_i


def _extract_statement_slots(statement):
def _extract_destination_slots(statement):
sets = set()
uses = set()

if isinstance(statement, nodes.Assignment):
for node in statement.destinations.contents:
if isinstance(node, nodes.Identifier):
if node.type == nodes.Identifier.T_SLOT:
sets.add(node.slot)
else:
# Anything else is a use action, not a set action
uses.update(_gather_slots(node))

uses.update(_gather_slots(statement.expressions))
elif isinstance(statement, (nodes.IteratorFor, nodes.NumericFor)):
uses = _gather_slots(statement.expressions)
elif isinstance(statement, nodes.Return):
uses = _gather_slots(statement.returns)
elif isinstance(statement, nodes.BlackHole):
uses = _gather_slots(statement.contents)
elif isinstance(statement, nodes.FunctionCall):
uses = _gather_slots(statement.arguments)
uses.update(_gather_slots(statement.function))
elif isinstance(statement, nodes.While):
uses = _gather_slots(statement.expression)

return sets, uses
for node in statement.destinations.contents:
if not isinstance(node, nodes.Identifier):
continue

if node.type == nodes.Identifier.T_SLOT:
sets.add(node.slot)

return sets


def _gather_slots(node):
Expand Down

0 comments on commit e0ebe38

Please sign in to comment.