From 165bb6c1344b98de7bef1d3c2b72147b4a40797a Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 16:05:20 -0300 Subject: canim: the renderer speaks the design language The blocks, their states and the tokens carry the catalogue's names: atoms in ui, chain/reg/slot in rows, insn with its line column, jump lane and annotations (read, write, taken or not, a call with its arguments, a return, a syscall) in disasm, bytes and hexdump with field paper and the reading column, the three splits and relayout in stage, the ties (thread, link and pin, projection, echo). A lens is a band over the whole context, its drawing left and its bytes right. Frames' spans on the stack, each instruction's line and a callee's parameter count come from the tracer. A gallery scene draws every block; the test compares six of its pages with pictures kept in test/gallery, drawn from a recording kept there too. The scenes are ported; the motion checks report no pop and no metronome in any of them. Co-Authored-By: Claude Fable 5.2 --- anim/src/root.zig | 97 ++++++++++++++++++++++++------------------------------- 1 file changed, 43 insertions(+), 54 deletions(-) (limited to 'anim/src/root.zig') diff --git a/anim/src/root.zig b/anim/src/root.zig index 82cf8d3..a69cda9 100644 --- a/anim/src/root.zig +++ b/anim/src/root.zig @@ -4,8 +4,8 @@ //! const canim = @import("canim"); //! const rec = canim.open(recordings.sort); //! const at = canim.cursor(s, rec, 0); // where the picture is -//! const ctx = canim.context(s, at, .{}); // the debugger's whole context -//! canim.establish(s, .{ ctx.clock, ctx.source, ctx.disasm, ctx.registers, ctx.stack, ctx.backtrace }); +//! const ctx = canim.context(s, at, .{ .split = canim.layout.split.beside }); // the debugger's whole context +//! canim.establish(s, .{ ctx.registers, ctx.stack, ctx.source, ctx.disasm, ctx.ties }); //! at.walk(s, .line, rec.call("sort", 0).enter); // play the program forward //! //! Every component is an `anim` object (`fadeIn`, `move`, ...) that draws @@ -26,19 +26,20 @@ pub const Now = cursors.Now; pub const Plan = cursors.Plan; pub const Levels = cursors.Levels; +pub const rows = @import("rows.zig"); +pub const Stage = @import("stage.zig").Stage; pub const Source = @import("source.zig").Source; const contexts = @import("context.zig"); pub const Registers = contexts.Registers; pub const Stack = contexts.Stack; pub const Backtrace = contexts.Backtrace; -pub const Disasm = contexts.Disasm; -pub const Locals = @import("registers.zig").Locals; +/// The registers' tag: what an address's ink says. +pub const contextLegend = contexts.legend; +pub const Disasm = @import("disasm.zig").Disasm; pub const calls = @import("calls.zig"); pub const CallTree = calls.Tree; -pub const Memory = @import("memory.zig").Memory; pub const Nodes = @import("nodes.zig").Nodes; -pub const Heap = @import("heap.zig").Heap; -pub const Hexdump = @import("hexdump.zig").Hexdump; +pub const hexdump = @import("hexdump.zig"); const tying = @import("ties.zig"); pub const Ties = tying.Ties; pub const Place = tying.Place; @@ -186,79 +187,67 @@ pub const Camera = struct { } }; -/// The debugger's whole context, the same in every scene: the state -/// column (every register followed as far as it points, the stack as a -/// telescope, the backtrace), and in the program column the source (all -/// of it, in a window) and the disassembly at the pc; and the clock. -/// A scene adds its lens at `split.lens`: a lens is never shown instead -/// of the machine it is drawn from. +/// The debugger's whole context, the same in every scene (design/README.md, +/// "5. The frame"): the state column (every register followed as far as it +/// points, the stack with its frames, the backtrace where there is room), +/// the program column (the whole source in a window, the disassembly at +/// the pc), the ties between them, and the clock. A scene adds its lens in +/// the band (`stage`): a lens is never shown instead of the machine. pub const Context = struct { + stage: *Stage, clock: anim.Obj, source: anim.Obj, disasm: anim.Obj, registers: anim.Obj, stack: anim.Obj, backtrace: anim.Obj, + /// The ties: add it after the lens, with `ties`. + cursor: Cursor, + quiet: bool, pub const Options = struct { - /// How the program column is shared (`layout.split`). + /// How the stage is shared (`layout.split`); `Stage.relayout` changes it. split: layout.Split = layout.split.beside, /// A program that makes system calls: see `Registers.syscalls`. syscalls: bool = false, /// An instrumented program: see `Registers.quiet`. quiet: bool = false, }; + + /// The ties between the panes, drawn over everything added before. + pub fn ties(c: Context, s: *anim.Frame) anim.Obj { + return add(s, Ties{ .cursor = c.cursor, .stage = c.stage, .quiet = c.quiet }); + } }; pub fn context(s: *anim.Frame, at: Cursor, options: Context.Options) Context { - const source_at = add(s, Source{ .cursor = at, .box = options.split.source }); - const disasm_at = add(s, Disasm{ .cursor = at, .box = options.split.disasm }); - const registers_at = add(s, Registers{ .cursor = at, .syscalls = options.syscalls, .quiet = options.quiet }); - const stack_at = add(s, Stack{ .cursor = at }); - const backtrace_at = add(s, Backtrace{ .cursor = at }); - return .{ .clock = add(s, Clock{ .cursor = at }), .source = source_at, .disasm = disasm_at, .registers = registers_at, .stack = stack_at, .backtrace = backtrace_at }; + const stage = Stage.init(s, options.split); + return .{ + .stage = stage, + .cursor = at, + .quiet = options.quiet, + .source = add(s, Source{ .cursor = at, .stage = stage }), + .disasm = add(s, Disasm{ .cursor = at, .stage = stage }), + .registers = add(s, Registers{ .cursor = at, .stage = stage, .syscalls = options.syscalls, .quiet = options.quiet }), + .stack = add(s, Stack{ .cursor = at, .stage = stage }), + .backtrace = add(s, Backtrace{ .cursor = at, .stage = stage }), + .clock = add(s, Clock{ .cursor = at }), + }; } -/// Any component (a struct of this module with a `box`), in the scene -/// where its box says. The functions below are this, by name. +/// Any component of this module in the scene: one with a `box` where its +/// box says; one on the stage (it reads its box there each frame) at the origin. pub fn add(s: *anim.Frame, component: anytype) anim.Obj { - return ui.place(s, component, component.box.x, component.box.y); + if (@hasField(@TypeOf(component), "box")) return ui.place(s, component, component.box.x, component.box.y); + return ui.place(s, component, 0, 0); } -pub fn source(s: *anim.Frame, options: Source) anim.Obj { - return add(s, options); -} -pub fn registers(s: *anim.Frame, options: Registers) anim.Obj { - return add(s, options); -} -pub fn stack(s: *anim.Frame, options: Stack) anim.Obj { - return add(s, options); -} -pub fn disasm(s: *anim.Frame, options: Disasm) anim.Obj { - return add(s, options); -} -pub fn locals(s: *anim.Frame, options: Locals) anim.Obj { - return add(s, options); -} pub fn callTree(s: *anim.Frame, options: CallTree) anim.Obj { return add(s, options); } -pub fn memory(s: *anim.Frame, options: Memory) anim.Obj { - return add(s, options); -} pub fn nodes(s: *anim.Frame, options: Nodes) anim.Obj { return add(s, options); } -pub fn heap(s: *anim.Frame, options: Heap) anim.Obj { - return add(s, options); -} -pub fn hexdump(s: *anim.Frame, options: Hexdump) anim.Obj { - return add(s, options); -} -/// The connections between panes. Add it after every view it is to join. -pub fn ties(s: *anim.Frame, options: Ties) anim.Obj { - return add(s, options); -} pub fn array(s: *anim.Frame, options: Array) anim.Obj { return add(s, options); } @@ -288,14 +277,14 @@ test { _ = Recording; _ = cursors; _ = @import("source.zig"); - _ = @import("registers.zig"); + _ = @import("stage.zig"); + _ = rows; _ = contexts; + _ = @import("disasm.zig"); _ = tying; _ = @import("hexdump.zig"); _ = calls; - _ = @import("memory.zig"); _ = @import("nodes.zig"); - _ = @import("heap.zig"); _ = @import("array.zig"); _ = @import("syscalls.zig"); _ = objects; -- cgit v1.3