diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-10 22:50:34 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-10 22:51:17 -0300 |
| commit | fa5d150ac6977264f0704e9af664f8150bd25127 (patch) | |
| tree | f18b56f22ef696208754097c9a13875b0a8b92e6 /design/mock/context.py | |
| parent | 7ebd23e8a5f4634981aa162905a3c4297b835d91 (diff) | |
| download | computeranim-fa5d150ac6977264f0704e9af664f8150bd25127.tar.gz computeranim-fa5d150ac6977264f0704e9af664f8150bd25127.zip | |
design: arc, a pointer to a row of its own panel is drawn
From the user, on the loupe's mock: a pointer in memory named a row two
above it and nothing showed it. In a dump, a loupe and the stack a
pointer whose target is a row of the same panel is an arc in a lane at
the panel's edge, as a jump is in the disassembly: quiet while it stands,
full ink in the step that writes or reads it, a stub when the target is
just off the window. A chain shares a lane. A loupe carries the arcs
among its own rows; the stack's frame chain gets one only when touched.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
Diffstat (limited to 'design/mock/context.py')
| -rw-r--r-- | design/mock/context.py | 76 |
1 files changed, 66 insertions, 10 deletions
diff --git a/design/mock/context.py b/design/mock/context.py index 069e894..8c99956 100644 --- a/design/mock/context.py +++ b/design/mock/context.py @@ -253,6 +253,41 @@ def pin_up(g, cx, y, names, ink, size, link=None, sw=3): g.t(cx + 9, by, " ".join(names[1:]), size, VELLUM, face) +def arcs(g, x, found, rows_y, lanes, touched=(), align=16): + """`arc`: for each (source row, field address, target address, ink), a pointer whose target row is in this + panel: from the source row's left, along a lane at x + lanes[k], to the target row's address, head first. Going + up it leaves its row at 9 and arrives at 15 (going down, 15 and 9), so a chain shares a lane; nested spans + take inner lanes, the longest outermost. Standing ones quiet (60% toward the page); those the step touches + full. A target out of the window, touched: a stub to the panel's rule. Returns how many were not drawn.""" + items = [] + for src, field, tgt, ink, edge in found: + ys = rows_y[src] + yt = rows_y.get(tgt - tgt % align) + if yt is None: + if field in touched and edge is not None: # out of the window: a stub, only for the step's pointer + up = edge < ys + items.append((abs(ys - edge), ys + (9 if up else 15), edge, ink, True, True)) + continue + up = yt < ys + items.append((abs(ys - yt), ys + (9 if up else 15), yt + (15 if up else 9), ink, field in touched, False)) + items.sort(key=lambda it: -it[0]) + taken, dropped = [[] for _ in lanes], 0 + for span, y0, y1, ink, hot, stub in items: + lo, hi = min(y0, y1), max(y0, y1) + k = next((k for k in range(len(lanes)) if all(hi < a or lo > z for a, z in taken[k])), None) + if k is None: + dropped += 1 + continue + taken[k].append((lo, hi)) + lx = x + lanes[k] + col = ink if hot else mix(ink, PAGE, 0.4) + if stub: + gen.arrow(g, [(x + 21, y0), (lx, y0), (lx, y1)], col, 2, r=4, hl=7, hw=8) + else: # from the row's left, to the row's left: the brackets and addresses untouched + gen.arrow(g, [(x + 21, y0), (lx, y0), (lx, y1), (x + 22, y1)], col, 2, r=4, hl=7, hw=8) + return dropped + + def bracket(g, x, y0, y1, ink, sw=2, serif=5, side=1): """A span of rows, marked at its edge: the end of a projection, or a thing that is a view of another.""" g.rect(x - sw / 2, y0, sw, y1 - y0, ink) @@ -297,7 +332,7 @@ def registers(g, y, regs, flags, marks): return where -def stack(g, y, rows, frames, note=None, rsp=None, roles=None): +def stack(g, y, rows, frames, note=None, rsp=None, roles=None, touched=(), chain_too=False): """rows: (slot, pins, links, end[, marks]). frames: (name, first row, last row), newest first: the backtrace, drawn on the words that are each frame; a first row under 0 runs above the window. The window is the newest frame's. A frame's name is never cut for a chain: the chains on the rows it sits on end 12 @@ -328,7 +363,7 @@ def stack(g, y, rows, frames, note=None, rsp=None, roles=None): yy = y0 + i * ROW ys.append(yy) if pins: - pin(g, RX + 10, yy, pins, STACK) + pin(g, RX + 16, yy, pins, STACK) if rsp is not None: # the offset from rsp, pwndbg's way: +18 off = slot - rsp g.t(RX + 172, b(yy), ("+%x" % off) if off >= 0 else ("-%x" % -off), S, FAINT, MONO, "end") @@ -342,6 +377,20 @@ def stack(g, y, rows, frames, note=None, rsp=None, roles=None): g.t(end_x, b(yy), text, S, ink, MONO, "end") end_x -= len(text) * A + 12 chain(g, first, yy, [(slot, STACK)] + links, end, marks[0] if marks else None, room=end_x, lead=lead) + # the arcs: a word holding the address of a slot in the window. The frame chain (a saved rbp) is the spans' + # already, and is drawn only when the step touches it. + slots = {r[0]: ys[i] for i, r in enumerate(rows)} + found = [] + for i, (slot, pins, links, end, *marks) in enumerate(rows): + if marks and marks[0].get("free") or not links: + continue + v = links[0][0] + is_chain = roles.get(i, ("",))[0] == "saved rbp" + if links[0][1] == STACK and (not is_chain or slot in touched or chain_too): + edge = y + TAG + 1 if v < rows[0][0] else ys[-1] + ROW + PAD - 1 + found.append((slot, slot, v, STACK, edge)) + arcs(g, RX, [(s0, f, t, ink, e) for s0, f, t, ink, e in found if t in slots or f in touched], slots, (4, 10), touched, + align=8) for i, name, x, ya, yb, ny, open_top, open_ in spans: ink = GOLD if i == 0 else RULE g.rect(x - 1, ya, 2, yb - ya, ink) @@ -468,7 +517,7 @@ def thread(g, ys, spans): # ---- the lens: a list, and beside it the bytes it is drawn from ------------------------- def fields(g, y, h, about, base, length, flist, mem, region, region_of, marks=(), title="its bytes", x=None, - framed=(), bare=False, rows_shown=None, more_rows=True): + framed=(), bare=False, rows_shown=None, more_rows=True, touched=(), withhold=None, hot=False): """`hexdump` by `fields`: the region a scene names, read by the fields it gives it, in the band's view. flist: (at, len, reads, big, mark) with reads in number | pointer | text | bytes. mem: {address: byte} of what the stop shown saw (or the kernel took); a byte not in it is unread. marks: the field marks framed as read. @@ -485,20 +534,21 @@ def fields(g, y, h, about, base, length, flist, mem, region, region_of, marks=() shown = rows_shown if rows_shown is not None else [r for r in range(total) if holds(r)] ys = {} digits = max(len("%x" % (base + 16 * r)) for r in shown) - shift = max(18 + digits * A + 12 - 132, 0) + shift = max(34 + digits * A + 12 - 132, 0) + found = [] bx = lambda i: X + 132 + shift + i * 30 + (12 if i >= 8 else 0) lead = shared([base + 16 * r for r in shown]) if len(shown) > 1 else 0 yy, last = y + TAG + PAD, None for r in shown: if last is not None and r > last + 1: # the rows left out: one row, and how many - more(g, X + 18 - 6, yy) - g.t(X + 18 + 30 + 36, b(yy), "%d rows" % (r - last - 1), S, FAINT, MONO) + more(g, X + 34 - 6, yy) + g.t(X + 34 + 30 + 36, b(yy), "%d rows" % (r - last - 1), S, FAINT, MONO) yy += ROW last = r a0 = base + 16 * r ys[a0] = yy - bracket(g, X + 7, yy + 3, yy + ROW - 3, mix(region, PAGE, 0.6)) - addr(g, X + 18, yy, a0, region, lead=lead) + bracket(g, X + 24, yy + 3, yy + ROW - 3, mix(region, PAGE, 0.6)) + addr(g, X + 34, yy, a0, region, lead=lead) runs, i = [], 0 while i < 16 and a0 + i < base + length: f = next((f for f in flist if base + f[0] <= a0 + i < base + f[0] + f[1]), None) @@ -544,6 +594,8 @@ def fields(g, y, h, about, base, length, flist, mem, region, region_of, marks=() g.t(x, b(yy) - 1, note, 18, FAINT, "sans") x += tw(note, 18, "sans") + A continue + if reads == "pointer" and word and base <= word < base + length: # a row of this panel: an arc too + found.append((a0, a0 + i0, word, region_of(word) or VELLUM, None)) if reads == "pointer": if word == 0: s_, sink = "NULL", DIM @@ -560,8 +612,12 @@ def fields(g, y, h, about, base, length, flist, mem, region, region_of, marks=() x += (len(s_) + 1) * A yy += ROW if more_rows and shown and shown[-1] < total - 1: # the rows after the last field: one row, and how many - more(g, X + 18 - 6, yy) - g.t(X + 18 + 30 + 36, b(yy), "%d rows" % (total - 1 - shown[-1]), S, FAINT, MONO) + more(g, X + 34 - 6, yy) + g.t(X + 34 + 30 + 36, b(yy), "%d rows" % (total - 1 - shown[-1]), S, FAINT, MONO) + top, foot = y + TAG + 1, yy + (ROW if more_rows and shown and shown[-1] < total - 1 else 0) + PAD - 1 + found = [(s0, f, t, ink, top if t < base + 16 * shown[0] else foot) for s0, f, t, ink, _ in found + if not (withhold and withhold[0] <= s0 < withhold[1] and withhold[0] <= t < withhold[1])] # a loupe has them + arcs(g, X, found, ys, (4, 10, 16), {f for _, f, _, _, _ in found} if hot else touched) # a loupe: all at full ink return ys |
