2009-04-20 19:44:45 -04:00
|
|
|
! Copyright (C) 2008, 2009 Slava Pestov.
|
2008-11-13 01:07:45 -05:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
|
|
|
USING: accessors arrays sequences kernel sequences assocs
|
|
|
|
namespaces stack-checker.recursive-state.tree ;
|
|
|
|
IN: stack-checker.recursive-state
|
|
|
|
|
2009-04-20 19:44:45 -04:00
|
|
|
TUPLE: recursive-state word quotations inline-words ;
|
2008-11-13 01:07:45 -05:00
|
|
|
|
|
|
|
: initial-recursive-state ( word -- state )
|
|
|
|
recursive-state new
|
2009-04-20 19:44:45 -04:00
|
|
|
swap >>word
|
|
|
|
f >>quotations
|
|
|
|
f >>inline-words ; inline
|
2008-11-13 01:07:45 -05:00
|
|
|
|
|
|
|
f initial-recursive-state recursive-state set-global
|
|
|
|
|
2009-04-20 19:44:45 -04:00
|
|
|
: add-local-quotation ( rstate quot -- rstate )
|
2008-11-13 01:07:45 -05:00
|
|
|
swap clone [ dupd store ] change-quotations ;
|
|
|
|
|
|
|
|
: add-inline-word ( word label -- rstate )
|
|
|
|
swap recursive-state get clone
|
|
|
|
[ store ] change-inline-words ;
|
|
|
|
|
|
|
|
: inline-recursive-label ( word -- label/f )
|
|
|
|
recursive-state get inline-words>> lookup ;
|
|
|
|
|
|
|
|
: recursive-quotation? ( quot -- ? )
|
|
|
|
recursive-state get quotations>> lookup ;
|