factor/library/kernel.factor

51 lines
1.1 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
2005-03-07 22:11:36 -05:00
UNION: boolean f t ;
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
: 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
: os ( -- arch )
#! Returns one of "unix" or "win32".
11 getenv ;
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.
19 ;
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
: >boolean t f ? ; inline
: and ( a b -- a&b ) f ? ; inline
: not ( a -- ~a ) f t ? ; inline
2005-01-13 14:41:08 -05:00
: or ( a b -- a|b ) t swap ? ; inline
2004-12-18 23:35:20 -05:00
: xor ( a b -- a^b ) dup not swap ? ; inline
2005-02-17 21:19:27 -05:00
IN: alien
! See compiler/alien.factor for the rest; this needs to be here
! since primitive stack effects involve alien inputs/outputs.
BUILTIN: dll 15 ;
BUILTIN: alien 16 ;