default and labels/
goto, the C language supports jumping directly
from one position in the code to another. Rust supports on structured control flow constructs.
This means that during translation, we need to somehow eliminate the unstructured control-flow
constructs C has. This module is where that happens.
In a nutshell, here are the steps:
- given an entry point C statement, translate it into a CFG consisting of
- simplify this CFG (by eliminating empty blocks that jump unconditionally to the next block)
- use the Relooper algorithm to convert this CFG into a sequence of
- place the declarations in the right place and produce a sequence of
- simplify that sequence of
Structure<Stmt>s into another such sequence
- convert the
Vec<Structure<Stmt>>back into a
This module contains stuff related to choosing better loops in Relooper. The problem is simple:
there is a point in the relooper algorithm where we commit to making a
This module contains stuff related to preserving and using information from the initial C
source to better decide when to produce
This modules handles converting a a control-flow graph
This modules handles converting
Generalized basic block.
A CFG graph of regular basic blocks.
This contains the information one needs to convert a C declaration in all the possible ways:
Stores information about translating C declarations to Rust statements. When seeing a C
declaration, we often don't know if it is already in the right place. The fix is to punt: we
put into a
The sole purpose of this structure is to accumulate information about what cases/default have been seen which translating the body of the switch.
Represents the control flow choices one can make when at the end of a
Reaching the end of a body without encountering a
These labels identify basic blocks in a regular CFG.
A Rust statement, or a comment
A Rust statement, or a C declaration, or a comment
These are the things that the relooper algorithm produces.
These labels identify structure basic blocks in a structure CFG.