dewolf icon indicating copy to clipboard operation
dewolf copied to clipboard

[Switch] Add configuration options

Open ebehner opened this issue 3 years ago • 0 comments

Proposal

Not everybody likes switch-constructs, or switch in switch-constructs or only switches with a certain number of cases. Thus, it would be beneficial if it is configurable.

Remarks: Since we start with restructuring smaller regions, we do not know whether a switch-construct may be a case node of another switch-construct when we restructure it. Additionally, we sometimes have to construct an initial switch with two cases, to get a switch with more cases, depending on the control flow graph.

Approach

Add decompiler options for

  • [ ] reconstruct switch at all (yes/no , default: yes)
  • [ ] minimum number of cases to reconstruct as a switch node (any integer > 2, default: 2)
  • [ ] nested switches (yes/no, default: yes)
  • [ ] Optional: additionally case limit for nested switches, perhaps also an upper bound here?

The ConditionAwareRefinement, that reconstructs switch nodes, should be untouched. For the overall option switch yes or no, simply modify the function construct_refined_ast in acyclic_restructuring.py. For all other options, this should be done after the restructuring. Either in a separate stage that only runs if these options are set or it could be done in the code generator. Simply rewrite the switch as if-else constructs if they do not fulfill any of the configuration options.

ebehner avatar Jan 13 '22 06:01 ebehner