ikarus/src/libhandlers.ss

84 lines
2.0 KiB
Scheme
Raw Normal View History

2006-11-23 19:44:29 -05:00
(primitive-set! 'error
(lambda args
(foreign-call "ik_error" args)))
(primitive-set! '$apply-nonprocedure-error-handler
(lambda (x)
(error 'apply "~s is not a procedure" x)))
(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)))
2006-12-07 02:14:02 -05:00
(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))))
2006-12-07 02:48:31 -05:00
(primitive-set! 'cadr-error
(lambda (x)
(error 'cadr "invalid list structure in ~s" x)))
2006-12-08 08:42:56 -05:00
(primitive-set! 'fx+-type-error
2006-12-08 06:12:35 -05:00
(lambda (x)
2006-12-08 08:42:56 -05:00
(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))))
2006-12-07 02:48:31 -05:00
2006-12-08 08:42:56 -05:00
(primitive-set! 'fx+-overflow-error
(lambda (x y)
(error 'fx+ "overflow")))
2006-12-21 09:49:30 -05:00
(primitive-set! '$do-event
2006-12-21 09:49:30 -05:00
(lambda ()
(if ($interrupted?)
(begin
($unset-interrupted!)
(error #f "Interrupted"))
(display "Engine Expired\n" (console-output-port)))))
2006-12-21 09:49:30 -05:00