factor/core/system/system.factor

75 lines
1.7 KiB
Factor
Raw Normal View History

! Copyright (C) 2007, 2010 Slava Pestov.
2007-09-20 18:09:08 -04:00
! See http://factorcode.org/license.txt for BSD license.
USING: assocs init kernel kernel.private make namespaces sequences strings ;
IN: system
2007-09-20 18:09:08 -04:00
2011-05-20 18:11:50 -04:00
SINGLETONS: x86.32 x86.64 arm ppc.32 ppc.64 ;
2008-04-02 17:32:58 -04:00
UNION: x86 x86.32 x86.64 ;
2011-05-20 18:11:50 -04:00
UNION: ppc ppc.32 ppc.64 ;
: cpu ( -- class ) \ cpu get-global ; foldable
2008-04-02 17:32:58 -04:00
SINGLETONS: windows macosx linux ;
2008-04-02 19:25:33 -04:00
UNION: unix macosx linux ;
2008-04-02 17:32:58 -04:00
: os ( -- class ) \ os get-global ; foldable
2008-04-02 17:32:58 -04:00
: vm-version ( -- string ) \ vm-version get-global ; foldable
: vm-git-label ( -- string ) \ vm-git-label get-global ; foldable
: vm-compiler ( -- string ) \ vm-compiler get-global ; foldable
: vm-compile-time ( -- string ) \ vm-compile-time get-global ; foldable
<PRIVATE
CONSTANT: string>cpu-hash H{
{ "x86.32" x86.32 }
{ "x86.64" x86.64 }
{ "arm" arm }
{ "ppc.32" ppc.32 }
{ "ppc.64" ppc.64 }
}
CONSTANT: string>os-hash H{
{ "windows" windows }
{ "macosx" macosx }
{ "linux" linux }
}
: key-for-value ( key hash -- val )
>alist [ first2 nip = ] with filter first first ;
: string>cpu ( str -- class )
string>cpu-hash at ;
: cpu>string ( class -- str )
string>cpu-hash key-for-value ;
2008-04-02 19:25:33 -04:00
: string>os ( str -- class )
string>os-hash at ;
: os>string ( class -- str )
string>os-hash key-for-value ;
2008-04-02 19:25:33 -04:00
PRIVATE>
2008-04-02 17:32:58 -04:00
2008-09-18 23:08:12 -04:00
: image ( -- path ) \ image get-global ;
: vm ( -- path ) \ vm get-global ;
: embedded? ( -- ? ) OBJ-EMBEDDED special-object ;
: exit ( n -- * ) do-shutdown-hooks (exit) ;
: version-info ( -- str )
! formatting vocab not available in this context.
[
"Factor " % vm-version % " (" % vm-git-label % ", " %
vm-compile-time % ") [" %
vm-compiler % " " % cpu cpu>string % "] on " % os os>string %
] "" make ;