factor/core/init/init.factor

33 lines
882 B
Factor
Raw Normal View History

2009-03-17 03:19:50 -04:00
! Copyright (C) 2004, 2009 Slava Pestov.
2007-09-20 18:09:08 -04:00
! See http://factorcode.org/license.txt for BSD license.
2009-05-01 09:21:31 -04:00
USING: continuations continuations.private kernel
kernel.private sequences assocs namespaces namespaces.private ;
2007-09-20 18:09:08 -04:00
IN: init
SYMBOL: startup-hooks
SYMBOL: shutdown-hooks
2007-09-20 18:09:08 -04:00
startup-hooks global [ drop V{ } clone ] cache drop
shutdown-hooks global [ drop V{ } clone ] cache drop
2007-09-20 18:09:08 -04:00
: do-hooks ( assoc -- )
[ nip call( -- ) ] assoc-each ;
2007-09-20 18:09:08 -04:00
: do-startup-hooks ( -- ) startup-hooks get do-hooks ;
: do-shutdown-hooks ( -- ) shutdown-hooks get do-hooks ;
: add-startup-hook ( quot name -- )
startup-hooks get
[ at [ drop ] [ call( -- ) ] if ]
[ set-at ] 3bi ;
: add-shutdown-hook ( quot name -- )
shutdown-hooks get set-at ;
2007-09-20 18:09:08 -04:00
2009-05-01 09:21:31 -04:00
: boot ( -- ) init-namespaces init-catchstack init-error-handler ;
2007-09-20 18:09:08 -04:00
: boot-quot ( -- quot ) 20 getenv ;
: set-boot-quot ( quot -- ) 20 setenv ;