* ikarus.handlers.ss is now complete

This commit is contained in:
Abdulaziz Ghuloum 2007-05-04 11:38:39 -04:00
parent a97798b598
commit 393ee8fbab
3 changed files with 99 additions and 92 deletions

Binary file not shown.

View File

@ -18,9 +18,17 @@
(library (ikarus system handlers)
(export interrupt-handler
$apply-nonprocedure-error-handler)
(import (except (ikarus) interrupt-handler))
(export
interrupt-handler $apply-nonprocedure-error-handler
$incorrect-args-error-handler $multiple-values-error $debug
$underflow-misaligned-error top-level-value-error car-error
cdr-error fxadd1-error fxsub1-error cadr-error fx+-type-error
fx+-types-error fx+-overflow-error $do-event)
(import (except (ikarus) interrupt-handler)
(only (scheme)
$interrupted?
$unset-interrupted!
top-level-bound?))
(define interrupt-handler
(make-parameter
@ -35,92 +43,77 @@
(define $apply-nonprocedure-error-handler
(lambda (x)
(error 'apply "~s is not a procedure" x)))
(define $incorrect-args-error-handler
(lambda (p n)
(error 'apply "incorrect number of argument (~s) to ~s" n p)))
(define $multiple-values-error
(lambda args
(error 'apply
"incorrect number of values ~s returned to single value context"
args)))
(define $debug
(lambda (x)
(foreign-call "ik_error" (cons "DEBUG" x))))
(define $underflow-misaligned-error
(lambda ()
(foreign-call "ik_error" "misaligned")))
(define top-level-value-error
(lambda (x)
(cond
[(symbol? x)
(if (top-level-bound? x)
(error 'top-level-value "BUG in ~s" x)
(error 'top-level-value "~s is unbound" x))]
[else
(error 'top-level-value "~s is not a symbol" x)])))
(define car-error
(lambda (x)
(error 'car "~s is not a pair" x)))
(define cdr-error
(lambda (x)
(error 'cdr "~s is not a pair" x)))
(define fxadd1-error
(lambda (x)
(if (fixnum? x)
(error 'fxadd1 "overflow")
(error 'fxadd1 "~s is not a fixnum" x))))
(define fxsub1-error
(lambda (x)
(if (fixnum? x)
(error 'fxsub1 "underflow")
(error 'fxsub1 "~s is not a fixnum" x))))
(define cadr-error
(lambda (x)
(error 'cadr "invalid list structure in ~s" x)))
(define fx+-type-error
(lambda (x)
(error 'fx+ "~s is not a fixnum" x)))
(define fx+-types-error
(lambda (x y)
(error 'fx+ "~s is not a fixnum"
(if (fixnum? x) y x))))
(define fx+-overflow-error
(lambda (x y)
(error 'fx+ "overflow")))
(define $do-event
(lambda ()
(if ($interrupted?)
(begin
($unset-interrupted!)
((interrupt-handler)))
(display "Engine Expired\n" (console-output-port)))))
)
(library (ikarus handlers)
(export)
(import (scheme))
(primitive-set! 'error
(lambda args
(foreign-call "ik_error" args)))
(primitive-set! '$incorrect-args-error-handler
(lambda (p n)
(error 'apply "incorrect number of argument (~s) to ~s" n p)))
(primitive-set! '$multiple-values-error
(lambda args
(error 'apply
"incorrect number of values ~s returned to single value context"
args)))
(primitive-set! '$debug
(lambda (x)
(foreign-call "ik_error" (cons "DEBUG" x))))
(primitive-set! '$underflow-misaligned-error
(lambda ()
(foreign-call "ik_error" "misaligned")))
(primitive-set! 'top-level-value-error
(lambda (x)
(cond
[(symbol? x)
(if (top-level-bound? x)
(error 'top-level-value "BUG in ~s" x)
(error 'top-level-value "~s is unbound" x))]
[else
(error 'top-level-value "~s is not a symbol" x)])))
(primitive-set! 'car-error
(lambda (x)
(error 'car "~s is not a pair" x)))
(primitive-set! 'cdr-error
(lambda (x)
(error 'cdr "~s is not a pair" x)))
(primitive-set! 'fxadd1-error
(lambda (x)
(if (fixnum? x)
(error 'fxadd1 "overflow")
(error 'fxadd1 "~s is not a fixnum" x))))
(primitive-set! 'fxsub1-error
(lambda (x)
(if (fixnum? x)
(error 'fxsub1 "underflow")
(error 'fxsub1 "~s is not a fixnum" x))))
(primitive-set! 'cadr-error
(lambda (x)
(error 'cadr "invalid list structure in ~s" x)))
(primitive-set! 'fx+-type-error
(lambda (x)
(error 'fx+ "~s is not a fixnum" x)))
(primitive-set! 'fx+-types-error
(lambda (x y)
(error 'fx+ "~s is not a fixnum"
(if (fixnum? x) y x))))
(primitive-set! 'fx+-overflow-error
(lambda (x y)
(error 'fx+ "overflow")))
(primitive-set! '$do-event
(lambda ()
(if ($interrupted?)
(begin
($unset-interrupted!)
((interrupt-handler)))
(display "Engine Expired\n" (console-output-port)))))
)

View File

@ -503,8 +503,22 @@
[current-library-collection s i]
[invoke-library s i]
[$apply-nonprocedure-error-handler s]
))
[$incorrect-args-error-handler s]
[$multiple-values-error s]
[$debug s]
[$underflow-misaligned-error s]
[top-level-value-error s]
[car-error s]
[cdr-error s]
[fxadd1-error s]
[fxsub1-error s]
[cadr-error s]
[fx+-type-error s]
[fx+-types-error s]
[fx+-overflow-error s]
[$do-event s]
))
(define scheme-env-junk