diff options
Diffstat (limited to 'anim/scenes/list.zig')
| -rw-r--r-- | anim/scenes/list.zig | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/anim/scenes/list.zig b/anim/scenes/list.zig index d6f1a76..b7e6c4a 100644 --- a/anim/scenes/list.zig +++ b/anim/scenes/list.zig @@ -6,8 +6,10 @@ //! trip round the loop is walked (each local strikes on the stack and in //! the table, then its tag slides to its node; the pointer's rewrite is //! armed with its old arrow going dashed, strikes, and the new arrow grows -//! to the node it lands on); the second trip is hurried, with a rest; the -//! third is walked again, and `head` takes the last node. +//! to the node it lands on); after its first load the pointer loaded is +//! opened in a loupe, and the `next` in it one deeper; the second trip is +//! hurried, with a rest; the third is walked again, and `head` takes the +//! last node. const anim = @import("anim"); const canim = @import("canim"); const recordings = @import("recordings"); @@ -32,17 +34,38 @@ fn frame(s: *anim.Frame) void { const split = canim.layout.split.subject; const ctx = canim.context(s, at, .{ .split = split }); const list = canim.nodes(s, .{ .cursor = at, .stage = ctx.stage, .root = "head", .track = &tracked }); + ctx.map.add(s, canim.Nodes{ .cursor = at, .stage = ctx.map.stage, .root = "head", .track = &tracked }); var says: canim.Narrator = .{}; + // The pointer just loaded, opened: rax holds `cur->next` after the + // first trip's line 21; a loupe under it, and one from that node's `next`. + const loaded = rec.lineMoment(22, rec.lineMoment(21, reverse.enter)); + const near = canim.loupe(s, .{ .cursor = at, .stage = ctx.stage, .from = .{ .register = "rax" } }); + const deeper = canim.loupe(s, .{ .cursor = at, .stage = ctx.stage, .from = .{ .field = .{ .loupe = near, .at = rec.register(loaded, "rax") + 8 } } }); const joins = ctx.ties(s); - // The nodes come in beside their bytes, one by one: three of them. - ctx.establish(s, .{ ctx.clock, ctx.registers, ctx.stack, ctx.source, ctx.disasm, list, joins }, 3); + // It opens on the map, the whole context unfolded: the first caption at + // 1 s, the dive into the working frame at 2.5 s, the first step at 5 s. + ctx.map.show(s, .{ ctx.clock, ctx.registers, ctx.stack, ctx.source, ctx.disasm, list, joins }); + s.wait(@max(t.establish - s.cursor, 0)); says.line(s, "A list is nodes on the heap, each holding the address of the next.\nReversing it moves no node: it rewrites every `next`."); + s.cursor = 2.5; + ctx.map.dive(s); // Three names are set up. const first_trip = rec.lineMoment(21, reverse.enter); at.walk(s, .line, first_trip); // The loop's caption leads the loop. says.line(s, "`next` remembers the way on, `cur->next` is turned round,\nand `prev` and `cur` each step along."); + at.walk(s, .line, loaded); + // A beat of its own: the pointer just loaded is opened, and the one in it. + says.line(s, "`rax` holds `cur->next`: under it opens the heap round that node,\nand from its `next`, one deeper, the node after it."); + near.open(s); + s.wait(t.beat); + deeper.open(s); + s.wait(2 * t.beat + t.loupe.open); + deeper.close(s); + s.wait(t.stagger * 3); + near.close(s); + s.wait(t.beat); const second_trip = rec.lineMoment(21, rec.lineMoment(24, first_trip)); at.walk(s, .line, second_trip); // Pacing: the second trip is the same, so hurried; it keeps its rest. |
