1 ! copyright (c) 2007, 2010 slava pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: assocs continuations init io kernel kernel.private make
4 math.parser namespaces sequences ;
7 PRIMITIVE: (exit) ( n -- * )
8 PRIMITIVE: nano-count ( -- ns )
10 SINGLETONS: x86.32 x86.64 arm ppc.32 ppc.64 ;
12 UNION: x86 x86.32 x86.64 ;
13 UNION: ppc ppc.32 ppc.64 ;
15 : cpu ( -- class ) \ cpu get-global ; foldable
17 SINGLETONS: windows macosx linux ;
19 UNION: unix macosx linux ;
21 : os ( -- class ) \ os get-global ; foldable
23 : vm-version ( -- string ) \ vm-version get-global ; foldable
25 : vm-git-label ( -- string ) \ vm-git-label get-global ; foldable
27 : vm-compiler ( -- string ) \ vm-compiler get-global ; foldable
29 : vm-compile-time ( -- string ) \ vm-compile-time get-global ; foldable
33 CONSTANT: string>cpu-hash H{
41 CONSTANT: string>os-hash H{
47 : key-for-value ( key hash -- val )
48 >alist [ second = ] with find nip first ;
50 : string>cpu ( str -- class )
53 : cpu>string ( class -- str )
54 string>cpu-hash key-for-value ;
56 : string>os ( str -- class )
59 : os>string ( class -- str )
60 string>os-hash key-for-value ;
64 : image ( -- path ) \ image get-global ;
66 : vm ( -- path ) \ vm get-global ;
68 : embedded? ( -- ? ) OBJ-EMBEDDED special-object ;
70 : version-info ( -- str )
71 ! formatting vocab not available in this context.
73 "Factor " % vm-version %
74 " " % cpu cpu>string %
75 " (" % build # ", " % vm-git-label % ", " %
76 vm-compile-time % ")\n[" %
77 vm-compiler % "] on " % os os>string %
81 [ do-shutdown-hooks (exit) ] ignore-errors
82 [ "Unexpected error during shutdown!" print ] ignore-errors