1 ! Copyright (C) 2004, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: continuations continuations.private kernel
4 kernel.private sequences assocs namespaces namespaces.private ;
10 startup-hooks global [ drop V{ } clone ] cache drop
11 shutdown-hooks global [ drop V{ } clone ] cache drop
13 : do-hooks ( assoc -- )
14 [ nip call( -- ) ] assoc-each ;
16 : do-startup-hooks ( -- ) startup-hooks get do-hooks ;
18 : do-shutdown-hooks ( -- ) shutdown-hooks get do-hooks ;
20 : add-startup-hook ( quot name -- )
22 [ at [ drop ] [ call( -- ) ] if ]
25 : add-shutdown-hook ( quot name -- )
26 shutdown-hooks get set-at ;
28 : boot ( -- ) init-namespaces init-catchstack init-error-handler ;
30 : boot-quot ( -- quot ) 20 getenv ;
32 : set-boot-quot ( quot -- ) 20 setenv ;