-
Notifications
You must be signed in to change notification settings - Fork 9
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
Refine Initial Switch Construction #113
Labels
feature-request
New feature or request
Comments
/cib |
Branch issue-113-Refine_Initial_Switch_Construction created! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Proposal
Detect switch nodes in nested if-conditions.
More precisely, when restructuring
test6
of binary test_condition.zip we do not reconstruct a switch, although it would improve readability.The CFG before the restructuring has the following form:
The restructuring starts with the region containing nodes 12, 14, and 15 and restructures it as an if-else. Step by step the restructuring adds first nodes 10 & 13, then 8 & 11, and so on to the region. Thus, we never have a sequence node where we start the initial switch node. Therefore, the resulting AST has the following form:
Approach
Improve the
InitialSwitchConstructer
as follows:In the function
construct
we first iterate over all sequence nodes. Add a second iteration over all conditions nodes with a body trying to construct an initial switch node from a condition node, i.e., something likeinitial_switch_constructor._try_to_construct_initial_switch_from_condition(cond_node)
.The condition node must have a concrete structure.
expr == const1
orexpr != const2
.condition_node.switch_branches()
)expr == const2
orexpr != const2
. The compared expression of both conditions must be the same.Here, is a possible reconstruction of a sequence node where two children are possible case nodes of a switch node.
The text was updated successfully, but these errors were encountered: