1 ! Copyright (c) 2007, 2010 slava pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors assocs continuations init io kernel
4 kernel.private make math.parser namespaces sequences splitting ;
7 PRIMITIVE: (exit) ( n -- * )
8 PRIMITIVE: disable-ctrl-break ( -- )
9 PRIMITIVE: enable-ctrl-break ( -- )
10 PRIMITIVE: nano-count ( -- ns )
12 SINGLETONS: x86.32 x86.64 arm ppc.32 ppc.64 ;
14 UNION: x86 x86.32 x86.64 ;
15 UNION: ppc ppc.32 ppc.64 ;
17 : cpu ( -- class ) \ cpu get-global ; foldable
19 SINGLETONS: windows macosx linux freebsd ;
22 UNION: unix macosx linux freebsd bsd ;
24 : os ( -- class ) \ os get-global ; foldable
26 : vm-version ( -- string ) \ vm-version get-global ;
28 : vm-git-label ( -- string ) \ vm-git-label get-global ;
30 : vm-git-ref ( -- string )
31 vm-git-label "-" split1-last drop ;
33 : vm-git-id ( -- string )
34 vm-git-label "-" split1-last nip ;
36 : vm-compiler ( -- string ) \ vm-compiler get-global ;
38 : vm-compile-time ( -- string ) \ vm-compile-time get-global ;
42 CONSTANT: string>cpu-hash H{
50 CONSTANT: string>os-hash H{
57 : string>cpu ( str -- class )
60 : string>os ( str -- class )
65 : image-path ( -- path ) \ image-path get-global ;
67 : vm-path ( -- path ) \ vm-path get-global ;
69 : embedded? ( -- ? ) OBJ-EMBEDDED special-object ;
71 : version-info ( -- str )
72 ! formatting vocab not available in this context.
74 "Factor " % vm-version %
78 vm-git-id 10 short head % ", " %
79 vm-compile-time % ")\n[" %
80 vm-compiler % "] on " % os name>> %
84 [ do-shutdown-hooks (exit) ] ignore-errors
85 [ "Unexpected error during shutdown!" print flush ] ignore-errors