From 2f27fbe0aa2da0f85d599c1e5f3ac14d025f590c Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 11 Nov 2026 13:22:07 -0300 Subject: canim: the graph of a function's blocks From the user. A blocks lens draws a function's basic blocks as boxes with their offsets and visit counts, loops in their lanes with the turn count, the path's last edges gold, the pc's block gold, and the disassembly as its view; leave and turn carry the mark along an edge, with the compare's flags framed for the edge chosen. On the map the graph takes the disassembly's place with its rows. The layout is a pure function, tested on sort, reverse and libc's open (twelve blocks the run never reached fold into six boxes). The sort scene walks one trip of its inner loop block by block and sprints the middle on the map. Every scene's linear rows carry a rule and a count at each block's head. The stack's panel no longer reads registers from the file on every draw: a frame is 20 ms where it was 57. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa --- anim/src/descent.zig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'anim/src/descent.zig') diff --git a/anim/src/descent.zig b/anim/src/descent.zig index d435b59..53d46c5 100644 --- a/anim/src/descent.zig +++ b/anim/src/descent.zig @@ -22,6 +22,7 @@ const ties = @import("ties.zig"); const map = @import("map.zig"); const context = @import("context.zig"); const disasm = @import("disasm.zig"); +const graph = @import("graph.zig"); const syscalls = @import("syscalls.zig"); const Stage = @import("stage.zig").Stage; const theme = ui.theme; @@ -255,6 +256,8 @@ pub const Descent = struct { var last_window: ?u8 = null; const dd: disasm.Disasm = .{ .cursor = d.cursor, .stage = d.stage }; const base: usize = if (going >= 0.5) 0 else 1; + // Each window's blocks (`graph`), read once: a rule over each one's first row, its visits where the row has room. + var rules: [8]?graph.Rules = @splat(null); for (placed_items.items) |p| { const v = u.faded(p.shows); const y = p.y + p.rise; @@ -305,7 +308,11 @@ pub const Descent = struct { } runs.add(line != null and line.? == current_line, y, y + m.row); // A row drawn twice (crossfading) counts once for the arguments that hang over the rows under it. - const hangs = dd.insn(v, now, row, y, box.w, widen0 + wide, line, line != last_line, current_line, lead, state, base, if (p.twin) covered_before > 0 else covered > 0, .{ addrs[0], addrs[n -| 1] }, null); + const covers = if (p.twin) covered_before > 0 else covered > 0; + const hangs = dd.insn(v, now, row, y, box.w, widen0 + wide, line, line != last_line, current_line, lead, state, base, covers, .{ addrs[0], addrs[n -| 1] }, null); + const w = @min(p.item.window, rules.len - 1); + if (rules[w] == null) rules[w] = graph.Rules.init(u.f.scratch, rec, now.marks, .{ row.addr, row.addr }, going); + rules[w].?.draw(v, row.addr, y, box.w, !covers and !row.outside and !dd.noted(v, now, row, y, state, base, .{ addrs[0], addrs[n -| 1] }, null)); if (!p.twin) covered_before = covered; covered = if (p.twin) @max(covered, hangs) else @max(covered -| 1, hangs); last_line = line; -- cgit v1.3