factor/library/tools/walker.factor

44 lines
1.1 KiB
Factor
Raw Normal View History

2005-03-07 22:11:36 -05:00
! Copyright (C) 2004, 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
2005-12-24 18:29:31 -05:00
IN: walker
USING: errors hashtables inspector interpreter io kernel
2006-05-15 01:01:47 -04:00
listener math namespaces prettyprint sequences strings
2005-12-24 18:29:31 -05:00
vectors words ;
2005-03-07 22:11:36 -05:00
2006-03-25 01:06:52 -05:00
: &s ( -- ) meta-d get stack. ;
2005-03-07 22:11:36 -05:00
2006-05-15 01:37:11 -04:00
: &r ( -- ) meta-r get stack. ;
2006-07-10 00:51:22 -04:00
: meta-c* ( -- seq ) meta-c get meta-callframe append ;
2005-03-07 22:11:36 -05:00
: &c ( -- ) meta-c* callstack. ;
2006-05-15 01:37:11 -04:00
: &get ( var -- value ) meta-name get hash-stack ;
2005-03-07 22:11:36 -05:00
: report ( -- ) callframe get callframe-scan get callframe. ;
2005-03-07 22:11:36 -05:00
2006-03-25 01:06:52 -05:00
: step ( -- ) next do-1 report ;
2005-03-07 22:11:36 -05:00
2006-03-25 01:06:52 -05:00
: into ( -- ) next do report ;
2006-03-25 01:06:52 -05:00
: end-walk ( -- )
save-callframe meta-interp continue ;
2005-03-07 22:11:36 -05:00
: walk-banner ( -- )
2006-05-15 01:37:11 -04:00
"&s &r &c show stepper stacks" print
2005-08-23 22:27:05 -04:00
"&get ( var -- value ) get stepper variable value" print
2005-08-21 01:17:37 -04:00
"step -- single step over" print
"into -- single step into" print
2005-09-24 23:21:09 -04:00
"bye -- continue execution" print
2005-03-07 22:11:36 -05:00
report ;
2005-09-28 20:09:10 -04:00
: set-walk-hooks ( -- )
[ meta-d get ] datastack-hook set
2005-09-28 20:09:10 -04:00
"walk " listener-prompt set ;
2005-03-07 22:11:36 -05:00
: walk ( quot -- )
continuation [
set-meta-interp pop-d drop (meta-call)
2006-07-10 00:51:22 -04:00
set-walk-hooks walk-banner (listener) end-walk
] with-scope ;