xprim.scm 1.2 KB

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