factor/library/kernel.factor

59 lines
1.3 KiB
Factor
Raw Normal View History

2005-01-28 23:55:22 -05:00
! Copyright (C) 2004, 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
2004-12-24 02:52:02 -05:00
IN: kernel
USING: generic kernel-internals vectors ;
2004-12-24 02:52:02 -05:00
UNION: boolean POSTPONE: f POSTPONE: t ;
2005-03-07 22:11:36 -05:00
COMPLEMENT: general-t f
2004-12-18 23:35:20 -05:00
GENERIC: hashcode ( obj -- n )
M: object hashcode drop 0 ;
GENERIC: = ( obj obj -- ? )
M: object = eq? ;
2005-01-28 23:55:22 -05:00
GENERIC: clone ( obj -- obj )
M: object clone ;
2004-10-09 15:14:49 -04:00
: set-boot ( quot -- )
#! Set the boot quotation.
8 setenv ;
: num-types ( -- n )
#! One more than the maximum value from type primitive.
2005-04-09 18:30:46 -04:00
21 ;
2004-12-18 23:35:20 -05:00
: ? ( cond t f -- t/f )
#! Push t if cond is true, otherwise push f.
rot [ drop ] [ nip ] ifte ; inline
DEFER: wrapper?
BUILTIN: wrapper 14 wrapper? { 1 "wrapped" "set-wrapped" } ;
M: wrapper = ( obj wrapper -- ? )
over wrapper? [ swap wrapped = ] [ 2drop f ] ifte ;
! defined in parse-syntax.factor
DEFER: not
DEFER: t?
2004-12-18 23:35:20 -05:00
: >boolean t f ? ; inline
2004-12-18 23:35:20 -05:00
: and ( a b -- a&b ) f ? ; inline
2005-01-13 14:41:08 -05:00
: or ( a b -- a|b ) t swap ? ; inline
2005-04-27 01:47:57 -04:00
: cpu ( -- arch ) 7 getenv ;
: os ( -- os ) 11 getenv ;
: win32? ( -- ? ) os "win32" = ;
: unix? ( -- ? )
os "freebsd" =
os "linux" = or
os "macosx" = or ;
: tag-mask BIN: 111 ; inline
: tag-bits 3 ; inline
: fixnum-tag BIN: 000 ; inline
: bignum-tag BIN: 001 ; inline
: cons-tag BIN: 010 ; inline
: object-tag BIN: 011 ; inline