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.32 arm.64 ppc.32 ppc.64 ;
14 UNION: x86 x86.32 x86.64 ;
15 UNION: arm arm.32 arm.64 ;
16 UNION: ppc ppc.32 ppc.64 ;
18 : cpu ( -- class ) \ cpu get-global ; foldable
20 SINGLETONS: windows macosx linux freebsd ;
23 UNION: unix macosx linux freebsd bsd ;
25 : os ( -- class ) \ os get-global ; foldable
27 : vm-version ( -- string ) \ vm-version get-global ;
29 : vm-git-label ( -- string ) \ vm-git-label get-global ;
31 : vm-git-ref ( -- string )
32 vm-git-label "-" split1-last drop ;
34 : vm-git-id ( -- string )
35 vm-git-label "-" split1-last nip ;
37 : vm-compiler ( -- string ) \ vm-compiler get-global ;
39 : vm-compile-time ( -- string ) \ vm-compile-time get-global ;
43 CONSTANT: string>cpu-hash H{
52 CONSTANT: string>os-hash H{
59 : string>cpu ( str -- class )
62 : string>os ( str -- class )
67 : image-path ( -- path ) \ image-path get-global ;
69 : vm-path ( -- path ) \ vm-path get-global ;
71 : embedded? ( -- ? ) OBJ-EMBEDDED special-object ;
73 : version-info ( -- str )
74 ! formatting vocab not available in this context.
76 "Factor " % vm-version %
80 vm-git-id 10 index-or-length head % ", " %
81 vm-compile-time % ")\n[" %
82 vm-compiler % "] on " % os name>> %
86 [ do-shutdown-hooks (exit) ] ignore-errors
87 [ "Unexpected error during shutdown!" print flush ] ignore-errors