Skip to content

Commit

Permalink
some progress, but still a lot of work
Browse files Browse the repository at this point in the history
  • Loading branch information
ebehner committed Jul 20, 2023
1 parent bd7662f commit 978feb5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,20 @@ def _clean_up_reachability(self, possible_switch_node: SwitchNodeCandidate, sibl

def _initialize_not_same_switch_nodes(self, possible_switch_node: SwitchNodeCandidate, sibling_reachability: SiblingReachability):
"""We do not care about siblings that are no code-nodes and reach all cases or are reached by all cases."""
# TODO: Find a way to construct the conflict graph
# maximal independent set is wanted
reaching_node: DefaultDict[AbstractSyntaxTreeNode, Set[AbstractSyntaxTreeNode]] = defaultdict(set)
reachable_from_node: Dict[AbstractSyntaxTreeNode, Set[AbstractSyntaxTreeNode]] = dict()
for node in reversed(sibling_reachability.sorted_nodes()):
reachable_from_node[node] = set().union(*(reachable_from_node[succ].union({succ}) for succ in sibling_reachability.reachable_siblings_of(node)))
for node, reachable_nodes in reachable_from_node.items():
for reaching in reachable_nodes:
reaching_node[reaching].add(node)


for node in sibling_reachability.sorted_nodes():
pass

if node in possible_switch_node:
continue
if sibling_reachability.reachable_siblings_of(node) or not sibling_reachability.siblings_reaching(node):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def _can_combine_switch_nodes(self, switch_nodes: List[SwitchNode]) -> bool:
:param switch_nodes: A list of switch nodes we want to combine.
"""
# TODO What if only some of them are combinable???
sibling_reachability = self.asforest.get_sibling_reachability_of_children_of(self._current_seq_node)
# The switch cases are all different, thus which switch comes first is irrelevant for the switch-nodes, but maybe not for the other children
sibling_reachability.remove_reachability_between(switch_nodes)
Expand Down

0 comments on commit 978feb5

Please sign in to comment.