123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- (define-module (utils inspection))
- (use-modules
- ;; SRFI 60: procedures for treating integers as bits
- (srfi srfi-60)
- (ice-9 format))
- (define-public format-bit-integer
- (lambda* (bit-int
- #:key
- (width 8)
- (padding-char #\0))
- (let ([format-string
- (string-join
- (list "~"
- (number->string width)
- "'" (list->string (list padding-char))
- ","
- "b"
- "~"
- "%")
- "")])
- (display (simple-format #f "format-string is: ~a\n" format-string))
- (format #t format-string bit-int))))
- (define-public display-bit-integer
- (lambda* (bit-integer
- #:optional (output-port (current-output-port))
- #:key
- (width 8)
- (padding-char #\0))
- (display (simple-format #f "DEBUG: integer to display: ~a\n" bit-integer) output-port)
- (display (format-bit-integer bit-integer #:width width #:padding-char padding-char)
- output-port)))
- (define display-hash-map
- (lambda* (hash-map
- #:optional (output-port (current-output-port))
- #:key
- (sep "\n")
- (end "\n")
- (format-entry-proc
- (lambda (entry)
- (format-bit-integer entry #:width 64))))
- (let loop ([remaining (hash-map->list cons hash-map)])
- (cond
- [(null? remaining)
- (display end output-port)
- 'done]
- [else
- (display (format-entry-proc (car remaining)) output-port)
- (display sep output-port)
- (loop (cdr remaining))]))))
|