2004-07-22 19:48:50 -04:00
|
|
|
! :folding=none:collapseFolds=1:
|
2004-07-17 18:35:09 -04:00
|
|
|
|
|
|
|
! $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.
|
|
|
|
|
2004-08-20 18:48:08 -04:00
|
|
|
IN: vectors
|
|
|
|
DEFER: vector=
|
2004-09-27 23:01:04 -04:00
|
|
|
DEFER: vector-hashcode
|
2004-08-20 18:48:08 -04:00
|
|
|
|
2004-07-16 02:26:21 -04:00
|
|
|
IN: kernel
|
|
|
|
USE: lists
|
2004-08-26 22:21:17 -04:00
|
|
|
USE: math
|
2004-12-10 18:38:40 -05:00
|
|
|
USE: math-internals
|
2004-07-16 02:26:21 -04:00
|
|
|
USE: strings
|
|
|
|
USE: vectors
|
|
|
|
USE: words
|
2004-08-20 18:48:08 -04:00
|
|
|
USE: vectors
|
2004-07-16 02:26:21 -04:00
|
|
|
|
2004-10-09 15:14:49 -04:00
|
|
|
: cpu ( -- arch )
|
|
|
|
#! Returns one of "x86" or "unknown".
|
2004-10-12 23:52:03 -04:00
|
|
|
7 getenv ;
|
2004-10-09 15:14:49 -04:00
|
|
|
|
2004-08-30 02:30:55 -04:00
|
|
|
! The 'fake vtable' used here speeds things up a lot.
|
|
|
|
! It is quite clumsy, however. A higher-level CLOS-style
|
|
|
|
! 'generic words' system will be built later.
|
|
|
|
|
|
|
|
: generic ( obj vtable -- )
|
2004-09-30 21:49:49 -04:00
|
|
|
>r dup type r> vector-nth execute ;
|
2004-08-30 02:30:55 -04:00
|
|
|
|
2004-09-30 21:49:49 -04:00
|
|
|
: 2generic ( n n vtable -- )
|
2004-09-19 00:33:40 -04:00
|
|
|
>r 2dup arithmetic-type r> vector-nth execute ;
|
|
|
|
|
2004-09-30 21:49:49 -04:00
|
|
|
: default-hashcode drop 0 ;
|
|
|
|
|
2004-07-16 02:26:21 -04:00
|
|
|
: hashcode ( obj -- hash )
|
|
|
|
#! If two objects are =, they must have equal hashcodes.
|
2004-08-30 02:30:55 -04:00
|
|
|
{
|
2004-10-31 14:36:42 -05:00
|
|
|
nop ! 0
|
|
|
|
word-hashcode ! 1
|
|
|
|
cons-hashcode ! 2
|
|
|
|
default-hashcode ! 3
|
|
|
|
>fixnum ! 4
|
|
|
|
>fixnum ! 5
|
|
|
|
default-hashcode ! 6
|
|
|
|
default-hashcode ! 7
|
|
|
|
default-hashcode ! 8
|
|
|
|
>fixnum ! 9
|
|
|
|
>fixnum ! 10
|
|
|
|
vector-hashcode ! 11
|
|
|
|
str-hashcode ! 12
|
|
|
|
sbuf-hashcode ! 13
|
|
|
|
default-hashcode ! 14
|
|
|
|
default-hashcode ! 15
|
|
|
|
default-hashcode ! 16
|
2004-08-30 02:30:55 -04:00
|
|
|
} generic ;
|
|
|
|
|
2004-09-19 17:39:28 -04:00
|
|
|
IN: math DEFER: number= ( defined later... )
|
|
|
|
IN: kernel
|
2004-09-27 23:01:04 -04:00
|
|
|
: = ( obj obj -- ? )
|
|
|
|
#! Push t if a is isomorphic to b.
|
2004-08-30 02:30:55 -04:00
|
|
|
{
|
2004-10-31 14:36:42 -05:00
|
|
|
number= ! 0
|
|
|
|
eq? ! 1
|
|
|
|
cons= ! 2
|
|
|
|
eq? ! 3
|
|
|
|
number= ! 4
|
|
|
|
number= ! 5
|
|
|
|
eq? ! 6
|
|
|
|
eq? ! 7
|
|
|
|
eq? ! 8
|
|
|
|
number= ! 9
|
|
|
|
number= ! 10
|
|
|
|
vector= ! 11
|
|
|
|
str= ! 12
|
|
|
|
sbuf= ! 13
|
|
|
|
eq? ! 14
|
|
|
|
eq? ! 15
|
|
|
|
eq? ! 16
|
|
|
|
} generic ;
|
2004-07-16 02:26:21 -04:00
|
|
|
|
2004-09-19 00:33:40 -04:00
|
|
|
: 2= ( a b c d -- ? )
|
|
|
|
#! Test if a = c, b = d.
|
2004-11-15 12:33:21 -05:00
|
|
|
rot = [ = ] [ 2drop f ] ifte ;
|
2004-09-19 00:33:40 -04:00
|
|
|
|
2004-10-09 15:14:49 -04:00
|
|
|
: set-boot ( quot -- )
|
|
|
|
#! Set the boot quotation.
|
|
|
|
8 setenv ;
|