2004-08-20 18:48:08 -04:00
|
|
|
! :folding=indent:collapseFolds=1:
|
|
|
|
|
|
|
|
! $Id$
|
|
|
|
!
|
|
|
|
! Copyright (C) 2004 Slava Pestov.
|
|
|
|
!
|
|
|
|
! Redistribution and use in source and binary forms, with or without
|
|
|
|
! modification, are permitted provided that the following conditions are met:
|
|
|
|
!
|
|
|
|
! 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
! this list of conditions and the following disclaimer.
|
|
|
|
!
|
|
|
|
! 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
! this list of conditions and the following disclaimer in the documentation
|
|
|
|
! and/or other materials provided with the distribution.
|
|
|
|
!
|
|
|
|
! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
|
|
! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
|
! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
|
! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
|
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
IN: errors
|
|
|
|
USE: arithmetic
|
|
|
|
USE: combinators
|
|
|
|
USE: continuations
|
|
|
|
USE: kernel
|
|
|
|
USE: lists
|
|
|
|
USE: logic
|
|
|
|
USE: namespaces
|
|
|
|
USE: prettyprint
|
|
|
|
USE: stack
|
|
|
|
USE: stdio
|
|
|
|
USE: strings
|
|
|
|
USE: unparser
|
|
|
|
USE: vectors
|
|
|
|
|
2004-08-22 23:02:29 -04:00
|
|
|
: expired-port-error ( obj -- )
|
|
|
|
"Expired port: " write . ;
|
2004-08-20 18:48:08 -04:00
|
|
|
|
2004-08-22 23:02:29 -04:00
|
|
|
: undefined-word-error ( obj -- )
|
|
|
|
"Undefined word: " write . ;
|
2004-08-20 18:48:08 -04:00
|
|
|
|
2004-08-22 23:02:29 -04:00
|
|
|
: type-check-error ( list -- )
|
|
|
|
"Type check error" print
|
|
|
|
uncons car dup "Object: " write .
|
|
|
|
"Object type: " write type-of type-name print
|
|
|
|
"Expected type: " write type-name print ;
|
|
|
|
|
|
|
|
: array-range-error ( list -- )
|
|
|
|
"Array range check error" print
|
|
|
|
unswons "Object: " write .
|
|
|
|
uncons car "Maximum index: " write .
|
|
|
|
"Requested index: " write . ;
|
|
|
|
|
|
|
|
: io-error ( list -- )
|
|
|
|
"I/O error in kernel function " write
|
|
|
|
unswons write ": " write car print ;
|
|
|
|
|
|
|
|
: numerical-comparison-error ( list -- )
|
|
|
|
"Cannot compare " write unswons unparse write
|
|
|
|
" with " write unparse print ;
|
|
|
|
|
|
|
|
: float-format-error ( list -- )
|
|
|
|
"Invalid floating point literal format: " write car . ;
|
2004-08-20 18:48:08 -04:00
|
|
|
|
2004-08-22 23:02:29 -04:00
|
|
|
: signal-error ( obj -- )
|
|
|
|
"Operating system signal " write . ;
|
2004-08-20 18:48:08 -04:00
|
|
|
|
2004-08-22 23:02:29 -04:00
|
|
|
: io-task-twice-error ( obj -- )
|
|
|
|
"Attempting to perform two simulatenous I/O operations on "
|
|
|
|
write . ;
|
|
|
|
|
|
|
|
: no-io-tasks-error ( obj -- )
|
|
|
|
"No I/O tasks" print ;
|
|
|
|
|
|
|
|
: kernel-error. ( obj n -- str )
|
|
|
|
{
|
|
|
|
expired-port-error
|
|
|
|
undefined-word-error
|
|
|
|
type-check-error
|
|
|
|
array-range-error
|
|
|
|
io-error
|
|
|
|
numerical-comparison-error
|
|
|
|
float-format-error
|
|
|
|
signal-error
|
|
|
|
io-task-twice-error
|
|
|
|
no-io-tasks-error
|
|
|
|
} vector-nth execute ;
|
|
|
|
|
|
|
|
: kernel-error? ( obj -- ? )
|
|
|
|
dup cons? [ uncons cons? swap fixnum? and ] [ drop f ] ifte ;
|
2004-08-20 18:48:08 -04:00
|
|
|
|
|
|
|
: error. ( error -- str )
|
2004-08-22 23:02:29 -04:00
|
|
|
dup kernel-error? [
|
|
|
|
uncons car swap kernel-error.
|
|
|
|
] [
|
|
|
|
dup string? [ print ] [ . ] ifte
|
|
|
|
] ifte ;
|