1 ! Copyright (C) 2007, 2010 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: assocs init kernel kernel.private namespaces strings sequences ;
6 SINGLETONS: x86.32 x86.64 arm ppc.32 ppc.64 ;
8 UNION: x86 x86.32 x86.64 ;
9 UNION: ppc ppc.32 ppc.64 ;
11 : cpu ( -- class ) \ cpu get-global ; foldable
13 SINGLETONS: windows macosx linux ;
15 UNION: unix macosx linux ;
17 : os ( -- class ) \ os get-global ; foldable
19 : version ( -- string ) \ version get-global ; foldable
21 : git-label ( -- string ) \ git-label get-global ; foldable
23 : vm-compiler ( -- string ) \ vm-compiler get-global ; foldable
25 : vm-compile-time ( -- string ) \ vm-compile-time get-global ; foldable
29 CONSTANT: string>cpu-hash H{
37 CONSTANT: string>os-hash H{
43 : key-for-value ( key hash -- val )
44 >alist [ first2 nip = ] with filter first first ;
46 : string>cpu ( str -- class )
49 : cpu>string ( class -- str )
50 string>cpu-hash key-for-value ;
52 : string>os ( str -- class )
55 : os>string ( class -- str )
56 string>os-hash key-for-value ;
60 : image ( -- path ) \ image get-global ;
62 : vm ( -- path ) \ vm get-global ;
64 : embedded? ( -- ? ) OBJ-EMBEDDED special-object ;
66 : exit ( n -- * ) do-shutdown-hooks (exit) ;
68 : version-info ( -- str )
69 ! formatting vocab not available in this context.
70 "Factor " version append " (" append git-label append ", " append
71 vm-compile-time append ") [" append vm-compiler append
72 " " append cpu cpu>string append "] on " append os os>string append ;