diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-10 14:48:26 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-10 15:14:31 -0300 |
| commit | 7e9bf9e6e85c6c6e7a400d4fa0b43b77133ed3cb (patch) | |
| tree | a6add92cd4dcbbf4c31cd1ce989d99b190258353 /anim/scenes/syscalls.zig | |
| parent | ed46c51fe127377eb1fde8dee83da984e0f61860 (diff) | |
| download | computeranim-7e9bf9e6e85c6c6e7a400d4fa0b43b77133ed3cb.tar.gz computeranim-7e9bf9e6e85c6c6e7a400d4fa0b43b77133ed3cb.zip | |
canim: animations of recordings, as a debugger's whole context with a lens beside it
A package of its own (anim/), on sketchbook's anim module and pardes's
syntax. A scene opens a recording, takes a cursor into it, and declares
blocks that read the moment the cursor is at: the state column (registers
each followed as a pointer and inked by where it points, the stack
telescope, the backtrace), the program column (the whole source, the
disassembly in address order, and the scene's lens: a node-link list over
a hexdump of its heap, array cells, a call tree, a syscall crossing), and
ties between them. Motion is a step told as a sentence (the line fires,
its effects cascade a level at a time, the mark moves on last), timed by
what the step contains; walk, hurry and sprint pace a loop. Five scenes
from real recordings of fib, a linked list, a sort and syscalls.
First drafts, by the agent's own handover: the frame of the design's
second revision, the hexdump lens and the ties; no disassembly
annotations, no gallery, scenes not yet reviewed against the mocks.
Diffstat (limited to 'anim/scenes/syscalls.zig')
| -rw-r--r-- | anim/scenes/syscalls.zig | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/anim/scenes/syscalls.zig b/anim/scenes/syscalls.zig new file mode 100644 index 0000000..1516251 --- /dev/null +++ b/anim/scenes/syscalls.zig @@ -0,0 +1,49 @@ +//! A program that needs the kernel four times: open, read, close, write. +//! The debugger's context, and the kernel's side of each call as the lens. +//! +//! How it moves (design/motion.md): no effect before its cause. Each call +//! has its own caption, up a second before the line fires; the registers +//! that carry it are framed one at a time; the arrow goes down through +//! the line, and only then does the kernel's side take the call: its +//! name, its rows, its card. The bytes are copied two frames apart; the +//! arrow comes back; `rax` is struck. A call is as long as what it does. +const anim = @import("anim"); +const canim = @import("canim"); +const recordings = @import("recordings"); + +pub const background = canim.background; +pub const scene = anim.Live(frame, struct {}); + +/// What the narrator says before each of main's calls, in order. +const lines = [_][]const u8{ + "`open`: a name goes down, and a small number comes back.\nThat number is the file from now on.", + "`read`: the kernel copies the file's bytes into `buf`,\nand says how many.", + "`close`: the number is handed back.", + "`write`: the same bytes go the other way,\nfrom `buf` to file number 1, the output.", +}; + +fn frame(s: *anim.Frame) void { + const rec = canim.open(recordings.hello); + // From main's first call to its last line. + var at = canim.cursor(s, rec, rec.lineMoment(6, rec.call("main", 0).enter)); + at.journey(.line, rec.lineMoment(10, at.first)); + const split = canim.layout.split.beside; + at.levels = .{ .source_rows = 8 }; + const ctx = canim.context(s, at, .{ .split = split, .syscalls = true }); + // The lens: the kernel's side of each call. + const kernel = canim.crossing(s, .{ .cursor = at, .box = split.lens, .focus = true }); + var says: canim.Narrator = .{}; + const t = canim.theme.time; + + const joins = canim.ties(s, .{ .cursor = at }); + canim.establish(s, .{ ctx.clock, ctx.source, ctx.disasm, ctx.registers, ctx.stack, ctx.backtrace, kernel, joins }); + says.line(s, "A program cannot open a file or reach the screen itself.\nIt asks the kernel, and waits."); + + // One call a phrase: its caption while nothing moves, then the crossing. + for (lines) |line| { + says.line(s, line); + canim.syscalls.step(at, s, .line); + s.wait(t.phrase_rest); + } + s.wait(t.before_cut - t.phrase_rest); +} |
