diff options
Diffstat (limited to 'design/mock/frame.py')
| -rw-r--r-- | design/mock/frame.py | 60 |
1 files changed, 19 insertions, 41 deletions
diff --git a/design/mock/frame.py b/design/mock/frame.py index 15b3933..209116f 100644 --- a/design/mock/frame.py +++ b/design/mock/frame.py @@ -1,11 +1,11 @@ #!/usr/bin/env python3 """The working frame reworked: the disassembly under the source in every split, the registers a scene does not -move folded three to a row, the stack given what that frees, and the `blocks` lens's drawing across the band. +move folded three to a row, the stack given what that frees, and the `blocks` lens's rings over the program column. python3 -B frame.py # 40-frame-beside, 41-frame-subject, 25-blocks-lens (.svg), 42-frame-layouts.png 40 and 41 are mocks 9 and 11 in the reworked frame (the same recording of targets/list, the same moments, each -pane's minimap from the map as map.py draws it); 25 is sort with the `blocks` lens (graph.py's track, the stop in +pane's minimap from the map as map.py draws it); 25 is sort with the `blocks` lens (graph.py's rings, the stop in sort-dbg.txt); 42 sets the three layouts weighed this round side by side, each as the list's `subject` and sort's `blocks`, at a third of their size: A (recommended) folds the quiet registers, B keeps all seventeen and gives the source's rows to the disassembly, C sets the registers in two columns. @@ -26,15 +26,17 @@ from context import (PAGE, RAISED, RULE, VELLUM, BRIGHT, DIM, FAINT, GOLD, HEAP, HERE = G.HERE TOP, FOOT = 48, 888 -WORDS = {6: "six", 8: "eight", 10: "ten", 11: "eleven", 12: "twelve", 13: "thirteen", 14: "fourteen", 15: "fifteen"} +WORDS = {6: "six", 8: "eight", 10: "ten", 11: "eleven", 12: "twelve", 13: "thirteen", 14: "fourteen", 15: "fifteen", + 20: "twenty", 22: "twenty-two"} # ---- the splits ------------------------------------------------------------------------------------------------- # What a scene gives its lens, and the program column's rows under it: (drawing, view, source, disassembly). The -# `blocks` lens has no view: its drawing is the band across both columns. -SPLITS = {"none": (0, 0, 14, 17), "beside": (152, 152, 8, 17), "subject": (296, 200, 8, 11), "blocks": (200, 0, 8, 15)} +# `blocks` lens has no view: its drawing (rings, 880 by 344) is over the program column, and the state column is +# the registers' and the stack's from the top. +SPLITS = {"none": (0, 0, 14, 17), "beside": (152, 152, 8, 17), "subject": (296, 200, 8, 11), "blocks": (344, 0, 6, 11)} LAYOUTS = { "A": dict(regs="fold", src=None, dis=None), # the splits above - "B": dict(regs="all", src=6, dis=lambda d: d + 2), # all seventeen rows; the source gives two rows + "B": dict(regs="all", src=6, dis=lambda d, s: d + s - 6), # all seventeen rows; the source gives to six "C": dict(regs="two", src=None, dis=None), # the registers in two columns of eight, rip across } @@ -44,22 +46,23 @@ def boxes(split, layout, quiet): band, view, src, dis = SPLITS[split] L = LAYOUTS[layout] if L["src"] is not None and split != "none": - src, dis = L["src"], L["dis"](dis) + src, dis = L["src"], L["dis"](dis, src) regs = {"fold": C.reg_rows(quiet), "all": 17, "two": 9}[L["regs"]] out = {} y = TOP + (band + 12 if band else 0) out["source"] = (64, y, ph(src)) out["disasm"] = (64, y + ph(src) + 12, ph(dis)) assert out["disasm"][1] + out["disasm"][2] == FOOT or split == "none", (split, layout, out) - ys = TOP + (view + 12 if view else band + 12 if split == "blocks" else 0) + ys = TOP + (view + 12 if view else 0) out["registers"] = (976, ys, ph(regs)) yk = ys + ph(regs) + 12 - out["stack"] = (976, yk, FOOT - yk) + words = (FOOT - yk - TAG - 8) // ROW + out["stack"] = (976, FOOT - ph(words), ph(words)) # a panel is 32 + 24n: what is left over is above it if band: out["drawing"] = (64, TOP, band) if view: out["view"] = (976, TOP, view) - return out, regs, (FOOT - yk - TAG - 8) // ROW + return out, regs, words # ---- the registers in two columns (layout C) ------------------------------------------------------------------ @@ -256,33 +259,7 @@ SORT_REGS = [("rax", [], ("int", 1)), ("rbx", [], ("int", 0)), ("rcx", [(0x40401 SORT_FLAGS = [("CF", 0, 0), ("PF", 0, 1), ("AF", 0, 1), ("ZF", 0, 0), ("SF", 0, 0), ("IF", 1, 0), ("DF", 0, 0), ("OF", 0, 0)] SORT_QUIET = ("rbx", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15") # sort moves the other eight SORT_SRC = open(HERE + "/../../anim/tools/sort.c").read().split("\n") -TEXT = G.read_dis("sort-clang.dis") # the program's text: swap, sort, main -FUNC = lambda a: "swap" if a < 0x401150 else "sort" if a < 0x401200 else "main" - - -def sort_disasm(g, y, n): - """n rows round the pc; each block's first row under a rule, its visits ranged right in the annotation's room - (the pill's count, in its digits); the trail's three rows and the pc's with what they did.""" - i = [r[0] for r in TEXT].index(G.PC) - lo = max(0, min(i - n // 2, len(TEXT) - n)) - st = G.sort_state(G.UPTO, G.PC, G.TRAIL_ROWS) - notes = dict(G.NOTES) - notes[0x4011a3] = [("7fffffffecd3 ", STACK), ("◂ ", FAINT), ("1", VELLUM)] - rows = [] - for a, ln, mn, ops, t, callee in TEXT[lo:lo + n]: - state = "cur" if a == G.PC else {0x4011a9: "trail0", 0x4011a6: "trail1", 0x4011a3: "trail2"}.get(a) - note = ("runs", notes[a]) if a in notes else ("text", callee, VELLUM) if mn == "call" else None - rows.append((a, ln, mn, [(t, CODE)] if t and (mn.startswith("j") or mn == "call") else [(ops, VELLUM)], - state, note)) - at = C.disasm(g, y, rows, "sort", 12) - for a in at: - if a in G.SORT_BL and a != "note": # a block's first row: the rule over it, its pill's digits - yy = at[a] - g.rect(C.LX + 2, yy, C.CW - 4, 2, RULE) - n_ = st["blocks"][a]["count"] - g.t(C.LX + C.CW - 12, b(yy), "×%d" % n_, S, FAINT, MONO, "end") - line12 = [at[r[0]] for r in rows if r[1] == 12 and r[0] < 0x4011af] - return at, (min(line12), max(line12) + ROW), lo +TEXT, FUNC = G.TEXT, G.FUNC def sort_strips(g, bx, lo, n, words): @@ -313,19 +290,20 @@ def sort_frame(g, layout="A", strips=True): """Mock 25 in a layout: the `blocks` lens across the band, the source and the disassembly under it.""" bx, nregs, words = boxes("blocks", layout, SORT_QUIET) st = G.sort_state(G.UPTO, G.PC, G.TRAIL_ROWS, G.NOTES) - G.track_lens(g, 64, TOP, 1792, 200, G.SORT_BL, G.SB[0], G.SORT_BASE, st, "the blocks of sort") + G.rings(g, 64, TOP, 880, 344, G.SORT_BL, G.SORT_BASE, st, G.SORT_RINGS, "the blocks of sort") src, dis = (bx["source"][2] - 32) // ROW, (bx["disasm"][2] - 32) // ROW C.LX, C.RX = 64, 976 M.strip(strips) first = max(1, 12 - src // 2) ys = C.source(g, bx["source"][1], src, SORT_SRC, first, 12, [14, 13], "sort.c", 22) - at, run, lo = sort_disasm(g, bx["disasm"][1], dis) + at, run, lo = G.sort_disasm(g, bx["disasm"][1], dis) M.strip(False) draw_registers(g, layout, bx["registers"][1], SORT_REGS, SORT_FLAGS, {}, SORT_QUIET) M.strip(strips) C.RX = 976 roles = {0: ("j, high half", VELLUM), 1: ("i, n", VELLUM), 2: ("saved rbp", DIM), 6: ("saved rbp", DIM)} - C.stack(g, bx["stack"][1], sort_slots(words), [("sort", 0, 3), ("main", 4, 7), ("libc.so.6+27781", 8, 29)], + C.stack(g, bx["stack"][1], sort_slots(words), [("sort", 0, 3), ("main", 4, 7), ("libc.so.6+27781", 8, 29), + ("__libc_start_main+137", 30, 41)], rsp=RSP_S, roles={k: v for k, v in roles.items() if k < words}, note="%s words from rsp" % WORDS[words]) M.strip(False) C.thread(g, ys, [run]) @@ -392,7 +370,7 @@ def sheet(out): "list, subject" if kind == "subject" else "sort, blocks", src, dis, regs, words) d.text((x, y + 352), lab, font=body, fill="#eee6d2") if kind == "blocks": - d.text((x, y + 378), "the graph across the band: 1792 by 200, whole", font=body, fill="#9aa6d9") + d.text((x, y + 378), "rings over the program column, 880 by 344: whole", font=body, fill="#9aa6d9") else: d.text((x, y + 378), "the drawing 296 and its view of 7 over the state column", font=body, fill="#9aa6d9") s.save(HERE + "/" + out) |
