ikarus/src/ikarus.handlers.ss

127 lines
2.9 KiB
Scheme
Raw Normal View History

2006-11-23 19:44:29 -05:00
(library (ikarus system parameters)
(export make-parameter)
(import (except (ikarus) make-parameter))
(define make-parameter
(case-lambda
[(x)
(case-lambda
[() x]
[(v) (set! x v)])]
[(x guard)
(unless (procedure? guard)
(error 'make-parameter "~s is not a procedure" guard))
(set! x (guard x))
(case-lambda
[() x]
[(v) (set! x (guard v))])])))
2007-05-04 11:25:04 -04:00
(library (ikarus system handlers)
(export interrupt-handler
$apply-nonprocedure-error-handler)
(import (except (ikarus) interrupt-handler))
(define interrupt-handler
(make-parameter
(lambda ()
(flush-output-port (console-output-port))
(error #f "interrupted"))
(lambda (x)
(if (procedure? x)
x
(error 'interrupt-handler "~s is not a procedure" x)))))
(define $apply-nonprocedure-error-handler
(lambda (x)
(error 'apply "~s is not a procedure" x)))
)
2007-04-30 01:06:00 -04:00
(library (ikarus handlers)
(export)
(import (scheme))
2006-11-23 19:44:29 -05:00
(primitive-set! 'error
(lambda args
(foreign-call "ik_error" args)))
2006-11-23 19:44:29 -05:00
(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!)
((interrupt-handler)))
(display "Engine Expired\n" (console-output-port)))))
2007-04-30 01:06:00 -04:00
)