topos.graphs.cfg.object

ControlFlowGraph Representation

The CFG translational functor’s image in the Topos E. Implements the Representation protocol and feeds the SIMPLE generator of ℋ.

Metrics emitted (namespace cfg.*):

cfg.cyclomatic — McCabe complexity (E - N + 2P, with P = 1). cfg.essential — essential complexity (structured-decomposition reduction). cfg.nesting_depth — maximum static nesting depth. cfg.longest_path — longest acyclic path (a rough proxy for path explosion).

class topos.graphs.cfg.object.ControlFlowGraph(blocks=<factory>, edges=<factory>, entry_id=0, exit_id=1)[source]

Bases: object

A language-independent control-flow graph built on UAST.

Construct via from_uast() for a fully-populated graph, or pass pre-computed blocks and edges for tests.

blocks
edges
entry_id = 0
exit_id = 1
property name
property dimension
classmethod from_uast(uast_root)[source]

Build a CFG from a UAST root, covering every callable.

successors(block_id)[source]
predecessors(block_id)[source]
metrics()[source]