| 
									
										
										
										
											2014-11-12 06:33:19 -05:00
										 |  |  | ! copyright (c) 2007, 2010 slava pestov. | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							| 
									
										
										
										
											2014-11-12 06:33:19 -05:00
										 |  |  | USING: assocs continuations init io kernel kernel.private make | 
					
						
							|  |  |  | math.parser namespaces sequences ;
 | 
					
						
							| 
									
										
										
										
											2009-05-02 14:45:38 -04:00
										 |  |  | 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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-04-02 18:07:38 -04:00
										 |  |  | UNION: x86 x86.32 x86.64 ;
 | 
					
						
							| 
									
										
										
										
											2011-05-20 18:11:50 -04:00
										 |  |  | UNION: ppc ppc.32 ppc.64 ;
 | 
					
						
							| 
									
										
										
										
											2008-04-02 18:07:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-10-02 06:15:05 -04:00
										 |  |  | : cpu ( -- class ) \ cpu get-global ; foldable
 | 
					
						
							| 
									
										
										
										
											2008-04-02 17:32:58 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-02 20:13:31 -04:00
										 |  |  | SINGLETONS: windows macosx linux ;
 | 
					
						
							| 
									
										
										
										
											2008-04-02 19:25:33 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-02 20:13:31 -04:00
										 |  |  | UNION: unix macosx linux ;
 | 
					
						
							| 
									
										
										
										
											2008-04-02 17:32:58 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-10-02 06:15:05 -04:00
										 |  |  | : os ( -- class ) \ os get-global ; foldable
 | 
					
						
							| 
									
										
										
										
											2008-04-02 17:32:58 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-25 11:26:06 -04:00
										 |  |  | : vm-version ( -- string ) \ vm-version get-global ; foldable
 | 
					
						
							| 
									
										
										
										
											2013-08-19 11:34:29 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-25 11:26:06 -04:00
										 |  |  | : vm-git-label ( -- string ) \ vm-git-label get-global ; foldable
 | 
					
						
							| 
									
										
										
										
											2013-08-19 11:34:29 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-01 16:32:07 -05:00
										 |  |  | : vm-compiler ( -- string ) \ vm-compiler get-global ; foldable
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-19 11:34:29 -04:00
										 |  |  | : vm-compile-time ( -- string ) \ vm-compile-time get-global ; foldable
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-04-02 18:07:38 -04:00
										 |  |  | <PRIVATE
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-19 11:34:29 -04:00
										 |  |  | 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 )
 | 
					
						
							| 
									
										
										
										
											2014-11-30 10:32:34 -05:00
										 |  |  |     >alist [ second = ] with find nip first ;
 | 
					
						
							| 
									
										
										
										
											2013-08-19 11:34:29 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-04-02 18:07:38 -04:00
										 |  |  | : string>cpu ( str -- class )
 | 
					
						
							| 
									
										
										
										
											2013-08-19 11:34:29 -04:00
										 |  |  |     string>cpu-hash at ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : cpu>string ( class -- str )
 | 
					
						
							|  |  |  |     string>cpu-hash key-for-value ;
 | 
					
						
							| 
									
										
										
										
											2008-04-02 18:07:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-04-02 19:25:33 -04:00
										 |  |  | : string>os ( str -- class )
 | 
					
						
							| 
									
										
										
										
											2013-08-19 11:34:29 -04:00
										 |  |  |     string>os-hash at ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : os>string ( class -- str )
 | 
					
						
							|  |  |  |     string>os-hash key-for-value ;
 | 
					
						
							| 
									
										
										
										
											2008-04-02 18:07:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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 ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-19 10:31:14 -04:00
										 |  |  | : embedded? ( -- ? ) OBJ-EMBEDDED special-object ;
 | 
					
						
							| 
									
										
										
										
											2013-08-19 11:34:29 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : version-info ( -- str )
 | 
					
						
							|  |  |  |     ! formatting vocab not available in this context. | 
					
						
							| 
									
										
										
										
											2013-08-25 11:41:39 -04:00
										 |  |  |     [ | 
					
						
							| 
									
										
										
										
											2014-11-11 19:44:00 -05:00
										 |  |  |         "Factor " % vm-version % | 
					
						
							| 
									
										
										
										
											2014-11-12 06:33:19 -05:00
										 |  |  |         " " % cpu cpu>string % | 
					
						
							| 
									
										
										
										
											2014-11-13 12:58:20 -05:00
										 |  |  |         " (" % build # ", " % vm-git-label % ", " % | 
					
						
							|  |  |  |         vm-compile-time % ")\n[" % | 
					
						
							| 
									
										
										
										
											2014-11-12 06:33:19 -05:00
										 |  |  |         vm-compiler % "] on " % os os>string % | 
					
						
							| 
									
										
										
										
											2013-08-25 11:41:39 -04:00
										 |  |  |     ] "" make ;
 | 
					
						
							| 
									
										
										
										
											2014-09-19 10:31:14 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : exit ( n -- * )
 | 
					
						
							|  |  |  |     [ do-shutdown-hooks (exit) ] ignore-errors
 | 
					
						
							|  |  |  |     [ "Unexpected error during shutdown!" print ] ignore-errors
 | 
					
						
							|  |  |  |     255 (exit) ;
 |