describe.scm 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. ; Part of Scheme 48 1.9. See file COPYING for notices and license.
  2. ; Authors: Richard Kelsey, Jonathan Rees
  3. (define (describe x)
  4. (if (and (stob? x)
  5. (< (stob-type x) least-b-vector-type))
  6. (let ((tag (string-append (number->string x) ": "))
  7. (len (bytes->cells (stob-length-in-bytes x))))
  8. (do ((i -1 (+ i 1)))
  9. ((= i len))
  10. (describe-1 (stob-ref x i) tag)))
  11. (describe-1 x "")))
  12. (define (describe-1 x addr)
  13. (cond ((fixnum? x) (display " fixnum ") (write (extract-fixnum x)))
  14. ((header? x)
  15. (display addr)
  16. (if (immutable-header? x)
  17. (display " immutable"))
  18. (display " header ")
  19. (let ((type (header-type x)))
  20. (if (< type stob-count)
  21. (write (vector-ref stob type))
  22. (write type)))
  23. (display " ")
  24. (write (header-length-in-bytes x)))
  25. ((immediate? x)
  26. (cond (else
  27. (display " immediate ")
  28. (let ((type (immediate-type x)))
  29. (if (< type imm-count)
  30. (write (vector-ref imm type))
  31. (write type)))
  32. (display " ")
  33. (write (immediate-info x)))))
  34. ((stob? x)
  35. (display " stob ") (write x))
  36. (else (display " ? ") (write x)))
  37. (newline))