# HG changeset patch # User Steve Losh # Date 1458906611 0 # Node ID 14e794b0242382c3beae23c35e8503a52c5b0741 # Parent d2aa6ee9382a5d84cdf4fd18c9010495252553af Prettify the heap printing a bit diff -r d2aa6ee9382a -r 14e794b02423 src/wam.lisp --- a/src/wam.lisp Fri Mar 25 11:49:46 2016 +0000 +++ b/src/wam.lisp Fri Mar 25 11:50:11 2016 +0000 @@ -123,22 +123,27 @@ (t ""))) (defun dump-heap (heap from to highlight) - (format t "~%Dumping heap...~%") - (format t "Heap size: ~A~%~%" (length heap)) - (format t "+------+-----+--------------+----------------------------+~%") - (format t "| ADDR | TYP | VALUE | DEBUG |~%") - (format t "+------+-----+--------------+----------------------------+~%") + (format t "HEAP SIZE: ~A~%" (length heap)) + (format t " +------+-----+--------------+----------------------------+~%") + (format t " | ADDR | TYP | VALUE | DEBUG |~%") + (format t " +------+-----+--------------+----------------------------+~%") + (when (> from 0) + (format t " | ⋮ | ⋮ | ⋮ | |~%")) (flet ((print-cell (i cell) - (format t "| ~4@A | ~A | ~12@A | ~26A |~A~%" - i - (cell-type-short-name cell) - (cell-value cell) - (heap-debug i cell) - (if (= i highlight) " <===" "")))) + (let ((hi (= i highlight))) + (format t "~A ~4@A | ~A | ~12@A | ~26A ~A~%" + (if hi "==> <" " |") + i + (cell-type-short-name cell) + (cell-value cell) + (heap-debug i cell) + (if hi "> <===" "|"))))) (loop :for i :from from :below to :do (print-cell i (aref heap i)))) - (format t "+------+-----+--------------+----------------------------+~%") + (when (< to (length heap)) + (format t " | ⋮ | ⋮ | ⋮ | |~%")) + (format t " +------+-----+--------------+----------------------------+~%") (values)) (defun dump-heap-full (heap)