Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TypeError@ast_nodes.py:283] TypeError: 'NoneType' object is not iterable #338

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
debug code
  • Loading branch information
mm4rks committed Sep 17, 2023
commit 4d6dfd26d0ce59e300c0b5cc2eb90ad8a4d623a9
3 changes: 3 additions & 0 deletions decompiler/pipeline/controlflowanalysis/restructuring.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from decompiler.structures.graphs.restructuring_graph.transition_cfg import TransitionBlock, TransitionCFG
from decompiler.structures.pseudo import Assignment, Constant, Integer, Variable
from decompiler.task import DecompilerTask
from decompiler.util.decoration import DecoratedAST, DecoratedCFG, DecoratedGraph


class PatternIndependentRestructuring(PipelineStage):
Expand Down Expand Up @@ -47,6 +48,8 @@ def run(self, task: DecompilerTask):
self.asforest = AbstractSyntaxForest.generate_from_code_nodes([node.ast for node in self.t_cfg], self.t_cfg.condition_handler)
self.options = RestructuringOptions.generate(task.options)

# DecoratedCFG.from_cfg(task.graph).export_plot("restructuring.png")

self.restructure_cfg()

assert len(self.t_cfg) == 1, f"The Transition Graph can only have one node after the restructuring."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _refine_code_nodes_with_complementary_conditions(self) -> None:
sibling_reachability.merge_siblings_to(condition_node, [ast_node_i, ast_node_j])
processed_to_branch.update([ast_node_i, ast_node_j])

sequence_node._sorted_children = sibling_reachability.sorted_nodes()
sequence_node._sorted_children = sibling_reachability.sorted_nodes() # set private property to None, expect tupe... TODO DBG

@staticmethod
def _get_possible_complementary_nodes(sequence_node: SeqNode):
Expand All @@ -92,6 +92,10 @@ def _structure_sequence_node(self, sequence_node: SeqNode) -> Set[SeqNode]:
newly_created_sequence_nodes: Set[SeqNode] = set()
sibling_reachability: SiblingReachability = self.asforest.get_sibling_reachability_of_children_of(sequence_node)

print("SEQUENCE NODE", sequence_node)
print("SEQUENCE NODE _SORTED_CHILDREN", sequence_node._sorted_children)
print("SEQUENCE NODE CHILDREN", sequence_node.children)

for child in list(sequence_node.children):
if child in visited:
continue
Expand Down
12 changes: 11 additions & 1 deletion decompiler/structures/ast/ast_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class SeqNode(AbstractSyntaxTreeNode):
def __init__(self, reaching_condition: LogicCondition, ast: Optional[AbstractSyntaxInterface] = None):
"""Init a new SequenceNode with a reaching condition and the ast it is contained in."""
super().__init__(reaching_condition, ast)
self._sorted_children: Tuple[AbstractSyntaxTreeNode, ...] = tuple()
self.__sorted_children: Tuple[AbstractSyntaxTreeNode, ...] = tuple()

def __str__(self) -> str:
"""Return a string representation of a SeqNode."""
Expand All @@ -275,6 +275,16 @@ def copy(self) -> SeqNode:
"""Return a copy of the ast node."""
return SeqNode(self.reaching_condition)

@property
def _sorted_children(self):
return self.__sorted_children

@_sorted_children.setter
def _sorted_children(self, value):
if value is None:
raise ValueError("_sorted_children cannot be set to None")
self.__sorted_children = value

@property
def children(self) -> Tuple[AbstractSyntaxTreeNode, ...]:
"""Return a tuple of all successors in execution order."""
Expand Down
Loading