code-vector.scm 648 B

12345678910111213141516171819202122
  1. ; Part of Scheme 48 1.9. See file COPYING for notices and license.
  2. ; Authors: Richard Kelsey, Jonathan Rees
  3. ; Code-vectors implemented as vectors.
  4. (define *code-vector-marker* (list '*code-vector-marker*))
  5. (define (make-code-vector len init)
  6. (let ((t (make-vector (+ len 1) init)))
  7. (vector-set! t 0 *code-vector-marker*)
  8. t))
  9. (define (code-vector? obj)
  10. (and (vector? obj)
  11. (> (vector-length obj) 0)
  12. (eq? (vector-ref obj 0) *code-vector-marker*)))
  13. (define (code-vector-length t) (- (vector-length t) 1))
  14. (define (code-vector-ref t i) (vector-ref t (+ i 1)))
  15. (define (code-vector-set! t i x) (vector-set! t (+ i 1) x))