describe.scm 1.1 KB

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