compiler/mir/utils

  Source   Edit

Non-essential utilities for interacting with or inspecting MIR code. No code should require any routines or types defined here in order to function.

For maximum availability, the imports of compiler modules should be kept as low as possible, so that the module can be imported without causing circular dependencies.

Procs

proc exprToStr(tree: MirTree; n: NodePosition; env: ptr MirEnv = nil;
               body: ptr MirBody = nil): string {.
    ...raises: [Exception, KeyError, ValueError], tags: [RootEffect].}
Renders the expression at n into a human-readable text representation.   Source   Edit
proc render(tree: MirTree; env: ptr MirEnv = nil; body: ptr MirBody = nil): string {.
    ...raises: [Exception, KeyError, ValueError], tags: [RootEffect].}
Renders tree into a human-readable text representation. The output is meant for debugging and tracing and is not guaranteed to have a stable format.   Source   Edit
proc stmtToStr(tree: MirTree; n: NodePosition; env: ptr MirEnv = nil;
               body: ptr MirBody = nil): string {.
    ...raises: [Exception, KeyError, ValueError], tags: [RootEffect].}
Renders the statement at n into a human-readable text representation.   Source   Edit
proc treeRepr(tree: MirTree; pos = NodePosition(0)): string {....raises: [],
    tags: [].}
Renders the node or sub-tree at pos to a string in a tree-layout- centric representation. This is meant for debugging purposes, with erroneous trees being handled gracefully.   Source   Edit