xprim.scm 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. ; Part of Scheme 48 1.9. See file COPYING for notices and license.
  2. ; Authors: Richard Kelsey, Jonathan Rees
  3. ; Hairier VM exceptions & interrupts.
  4. ; Enable generic arithmetic, informative error messages, etc.
  5. ; Deal with optional arguments, etc. to primitives.
  6. ; This is not necessarily the cleanest way to do this, and certainly not
  7. ; the most efficient, but for the time being it's the most expedient.
  8. ; We don't want to depend on tables. But if we did, we might do this:
  9. ;(define (closure-hash closure)
  10. ; (let ((cv (vector-ref (closure-template closure) 0))) ;template-ref
  11. ; (do ((h 0 (+ h (code-vector-ref cv i)))
  12. ; (i (- (code-vector-length cv) 1) (- i 1)))
  13. ; ((< i 0) h))))
  14. ;(define wna-handlers (make-table closure-hash))
  15. ;(define-vm-exception-handler (enum op check-nargs=)
  16. ; (lambda (opcode reason proc args)
  17. ; (let ((probe (assq proc *wna-handlers*)))
  18. ; (if probe
  19. ; ((cdr probe) args)
  20. ; (signal-vm-exception opcode reason proc args)))))
  21. (define *wna-handlers* '())
  22. (define (define-wna-handler proc handler)
  23. (set! *wna-handlers* (cons (cons proc handler) *wna-handlers*)))
  24. (define op/check-nargs= (enum op protocol)) ; temporary hack
  25. (define (wna-lose proc args)
  26. (signal-vm-exception op/check-nargs= #f proc args)) ; lost our reason