Implements an analysis pass for creating a structure control-flow representation from the unstructured, goto-based MIR.
Types
Stmt = object kind*: StmtKind sub*: int ## for block-like statements, index of the sub statement, or 0 (no ## sub statement) next*: int ## forms a singly-linked list. 0 terminates the list n*: NodePosition ## meaning depends on the kind
- Source Edit
Procs
proc optimize(stmts: var seq[Stmt]) {....raises: [], tags: [].}
-
Removes the following unecessary constructs:
- scopes in the tailing position of an 'if' or 'loop'
- scopes in the tailing position of other scopes
- empty scopes
proc pretty(stmts: seq[Stmt]): string {....raises: [], tags: [].}
- Meant for debugging. Renders the statement as an indented tree. Source Edit
proc toStructured(tree): seq[Stmt] {....raises: [KeyError], tags: [].}
- Computes a control-flow focused representation of tree, where all control-flow is structured, preserving scope information. Source Edit