summaryrefslogtreecommitdiff
path: root/design/mock/dense.py
diff options
context:
space:
mode:
Diffstat (limited to 'design/mock/dense.py')
-rw-r--r--design/mock/dense.py85
1 files changed, 7 insertions, 78 deletions
diff --git a/design/mock/dense.py b/design/mock/dense.py
index cb047ac..4017d69 100644
--- a/design/mock/dense.py
+++ b/design/mock/dense.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""The frame on the 4K stage: four columns of 880, the context at mono 20, four times what 1080 held.
- python3 -B dense.py # writes 15-marks.svg, 16-none.svg, 17-subject.svg, 18-loupes.svg
+ python3 -B dense.py # writes 15-marks.svg; and is the data and the map's columns for map.py
The blocks are context.py's, placed on the 4K stage's columns; what is new here is the stage, the thread across
the gutter, the `loupe`, and the marks sheet. The moment is real: a fresh recording of the same `targets/list`,
@@ -254,13 +254,14 @@ def caption4(g, lines):
y += 108
-def loupe(g, x, y, title, note, base, flist, framed, depth):
+def loupe(g, x, y, title, note, base, flist, framed, depth, rows=9):
"""`loupe`: the memory round a pointer's target, floating over the context, tied to the pointer it opens
from. Nine rows, the target's in the middle; the target framed bright. Lifted: its own surface, a shadow
under it, deeper for a loupe opened from another. Returns its rows' y."""
- h = ph(9)
+ h = ph(rows)
sx, sy = (12, 16) if depth == 1 else (20, 26)
- g.rect(x + sx, y + sy, CW, h, SHADE)
+ if depth: # on the map a loupe is a panel of its own: lifted, but no shadow
+ g.rect(x + sx, y + sy, CW, h, SHADE)
g.rect(x, y, CW, h, LIFT)
g.rect(x, y, CW, TAG, LIFT_TAG)
g.frame(x, y, CW, h, DIM, 2)
@@ -269,7 +270,8 @@ def loupe(g, x, y, title, note, base, flist, framed, depth):
g.t(xx, y + 18, s_, S, ink, MONO)
xx += len(s_) * A
g.t(x + CW - 10, y + 18, note, 18, DIM, "sans", "end")
- return C.fields(g, y, h, "", base, 144, flist, MEM, HEAP, region, framed=framed, bare=True, x=x)
+ return C.fields(g, y, h, "", base, 16 * rows, flist, MEM, HEAP, region, framed=framed, bare=True, x=x,
+ more_rows=False)
def stem(g, pts):
@@ -278,76 +280,6 @@ def stem(g, pts):
# ---- the frames ----------------------------------------------------------------------------------------
-def frame_none(name, step, loupes=False):
- """`none` on the 4K stage: source | disassembly | registers, backtrace, memory | stack."""
- g = Svg()
- put(COL[0])
- ys = C.source(g, TOP4, 69, SRC, 1, 21, [], "list.c", 42)
- put(COL[1])
- at = C.disasm(g, TOP4, window(69, step), "reverse", 21)
- thread_across(g, ys, [(at[0x1001926], at[0x1001926] + ROW)])
- put(COL[2])
- marks = {"rax": {0: "tick"}, "rcx": {0: "tick"}, "rdi": {0: "strike" if step else "tick"}}
- where = C.registers(g, TOP4, regs(step), FLAGS, marks)
- C.backtrace(g, 548, 416, BT, x=COL[2], note="newest on top")
- C.fields(g, 976, 808, "the heap, round what the step reads", 0x1004000, 512,
- heap_fields(0x1004000, 512, 0x1004098), MEM, HEAP, region, marks=(9,) if step else (), title="memory")
- put(COL[3])
- C.stack(g, TOP4, stack_rows(69), FRAMES, note="69 words from rsp", rsp=RSP, roles=roles(69))
- if loupes:
- ry = where["rdi"]
- x1, y1 = 2728, ry
- r1 = loupe(g, x1, y1, [("rdi", DIM), (" → ", FAINT), ("1004070", HEAP)], "heap · struct node, 16 bytes",
- 0x1004030, heap_fields(0x1004030, 144), [(0x1004070 - 0x1004030, 16)], 1)
- stem(g, [(COL[2] + 72 + 7 * A + 30 + A + 16, ry + 12), (x1, ry + 12)]) # from the end of rdi's chain
- # the next word in it opens the next: the field's bytes bracketed, a stem down into the deeper loupe
- fy = r1[0x1004070]
- bx0 = x1 + 132 + 8 * 30 + 12 - 4
- bx1 = x1 + 132 + 15 * 30 + 12 + 28
- g.rect(bx0, fy + ROW + 1, bx1 - bx0, 3, HEAP)
- x2, y2 = x1 + 120, fy + ROW + 34
- loupe(g, x2, y2, [("1004078", HEAP), (" → ", FAINT), ("1004050", HEAP)], "heap · struct node, 16 bytes",
- 0x1004010, heap_fields(0x1004010, 144), [(0x1004050 - 0x1004010, 16)], 2)
- stem(g, [((bx0 + bx1) / 2, fy + ROW + 4), ((bx0 + bx1) / 2, y2)])
- clock4(g, 3 if step else 2, 4)
- if loupes:
- caption4(g, [[("The load is done: ",), ("rdi", "mono"), (" holds ",), ("1004070", "mono"),
- (", and beside it the heap round it opens.",)],
- [("Its ",), ("next", "mono"), (" word opens the node after it, one deeper.",)]])
- else:
- caption4(g, [[("Stopped in ",), ("reverse", "mono"), (", about to load ",), ("head->next", "mono"), (".",)],
- [("rdi", "mono"), (" points at a node; the word after its value is the next node.",)]])
- g.save(name)
-
-
-def frame_subject(name):
- """`subject` on the 4K stage, mid-step: the list drawn twice the size over the program's two columns, its
- bytes over the third, the context under and beside them."""
- g = Svg()
- band = 604
- put(COL[2])
- view = C.fields(g, TOP4, 800, "the heap, 1004000 to 10041ff", 0x1004000, 512,
- heap_fields(0x1004000, 512, 0x1004098), MEM, HEAP, region, marks=(9,))
- where = C.registers(g, 908, regs(True), FLAGS, {"rax": {0: "tick"}, "rcx": {0: "tick"}, "rdi": {0: "strike"}})
- C.backtrace(g, 1360, 424, BT, x=COL[2], note="newest on top")
- put(COL[0])
- pins = {0x10040b0: ["rcx"], 0x1004090: ["rax"], 0x1004070: ["rdi"]}
- C.RX = COL[2] # the link leaves the registers, the projection the view
- C.lens(g, TOP4, band, 800, NODES, pins, {"tick": [0x10040b8], "read": 0x1004098}, 0x1004000, 32,
- link_from=(where["rdi"], "rdi"), subject=True, dw=2 * CW + 32, k=2, view_rows=view)
- put(COL[0])
- ys = C.source(g, TOP4 + band + 12, 43, SRC, 1, 21, [], "list.c", 42)
- put(COL[1])
- at = C.disasm(g, TOP4 + band + 12, window(43, True), "reverse", 21)
- thread_across(g, ys, [(at[0x1001926], at[0x1001926] + ROW)])
- put(COL[3])
- C.stack(g, TOP4, stack_rows(69), FRAMES, note="69 words from rsp", rsp=RSP, roles=roles(69))
- clock4(g, 2, 4)
- caption4(g, [[("The load read the word at ",), ("1004098", "mono"), (": the address of the next node.",)],
- [("rdi", "mono"), (" holds it now, and points at the node whose value is 9.",)]])
- g.save(name)
-
-
def frame_marks(name):
"""Mock 15: current, struck and held, as the first videos drew them (A), as the catalogue now does (B), and
the other reading of "white, with less opacity" (C), on real rows of the same moment and the one after."""
@@ -436,6 +368,3 @@ def frame_marks(name):
if __name__ == "__main__":
frame_marks("15-marks")
- frame_none("16-none", False)
- frame_subject("17-subject")
- frame_none("18-loupes", True, loupes=True)