2006-05-02 06:05:58 -04:00
|
|
|
! Copyright (C) 2003, 2006 Slava Pestov.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
|
|
|
IN: kernel-internals
|
|
|
|
USING: vectors ;
|
|
|
|
|
|
|
|
: catchstack* ( -- cs ) 6 getenv { vector } declare ; inline
|
|
|
|
|
2005-09-22 21:01:55 -04:00
|
|
|
IN: errors
|
2005-11-12 00:37:24 -05:00
|
|
|
USING: kernel kernel-internals ;
|
2005-09-22 21:01:55 -04:00
|
|
|
|
2005-11-12 00:37:24 -05:00
|
|
|
: catchstack ( -- cs ) catchstack* clone ; inline
|
2006-05-18 01:08:09 -04:00
|
|
|
: set-catchstack ( cs -- ) >vector 6 setenv ; inline
|
2005-09-22 21:01:55 -04:00
|
|
|
|
2005-09-14 00:37:50 -04:00
|
|
|
IN: kernel
|
2005-09-22 21:01:55 -04:00
|
|
|
USING: namespaces sequences ;
|
2004-07-16 02:26:21 -04:00
|
|
|
|
2006-05-14 23:09:47 -04:00
|
|
|
TUPLE: continuation data retain call name catch ;
|
2005-09-24 23:21:09 -04:00
|
|
|
|
2005-09-14 00:37:50 -04:00
|
|
|
: continuation ( -- interp )
|
2006-05-18 22:00:11 -04:00
|
|
|
datastack retainstack callstack dup pop* dup pop* dup pop*
|
2005-09-18 23:22:58 -04:00
|
|
|
namestack catchstack <continuation> ; inline
|
2004-07-16 02:26:21 -04:00
|
|
|
|
2006-05-14 23:09:47 -04:00
|
|
|
: >continuation< ( continuation -- data retain call name catch )
|
2005-09-18 23:22:58 -04:00
|
|
|
[ continuation-data ] keep
|
2006-05-14 23:09:47 -04:00
|
|
|
[ continuation-retain ] keep
|
2005-09-18 23:22:58 -04:00
|
|
|
[ continuation-call ] keep
|
|
|
|
[ continuation-name ] keep
|
|
|
|
continuation-catch ; inline
|
2005-06-15 23:27:28 -04:00
|
|
|
|
2005-09-22 21:01:55 -04:00
|
|
|
: ifcc ( terminator balance -- | quot: continuation -- )
|
|
|
|
[
|
2005-09-22 23:18:12 -04:00
|
|
|
continuation
|
2005-09-24 23:21:09 -04:00
|
|
|
dup continuation-data f over push f swap push dup
|
2005-09-24 15:21:17 -04:00
|
|
|
] call 2swap if ; inline
|
2005-09-22 21:01:55 -04:00
|
|
|
|
2006-01-06 23:10:02 -05:00
|
|
|
: callcc0 [ drop ] ifcc ; inline
|
2005-09-22 21:01:55 -04:00
|
|
|
|
2005-09-14 00:37:50 -04:00
|
|
|
: continue ( continuation -- )
|
2005-12-13 17:33:58 -05:00
|
|
|
>continuation<
|
2006-05-14 23:09:47 -04:00
|
|
|
set-catchstack
|
|
|
|
set-namestack
|
|
|
|
set-callstack
|
|
|
|
set-retainstack
|
|
|
|
set-datastack ;
|
2005-12-13 17:33:58 -05:00
|
|
|
inline
|
2005-09-14 00:37:50 -04:00
|
|
|
|
2005-09-23 01:22:04 -04:00
|
|
|
: (continue-with) 9 getenv ;
|
|
|
|
|
2006-01-06 23:10:02 -05:00
|
|
|
: callcc1 [ drop (continue-with) ] ifcc ; inline
|
2005-09-23 01:22:04 -04:00
|
|
|
|
2006-01-06 23:10:02 -05:00
|
|
|
: continue-with swap 9 setenv continue ; inline
|