walk now wraps the whole thing in a recover with a breakpoint so you can step back from an error

db4
Slava Pestov 2008-03-11 21:59:41 -05:00
parent 3c95b7813a
commit 5e81f59359
1 changed files with 9 additions and 6 deletions

View File

@ -32,14 +32,17 @@ SYMBOL: walking-thread
\ break t "break?" set-word-prop \ break t "break?" set-word-prop
: walk ( quot -- quot' )
\ break add* [ break rethrow ] recover ;
: add-breakpoint ( quot -- quot' ) : add-breakpoint ( quot -- quot' )
dup [ break ] head? [ \ break add* ] unless ; dup [ break ] head? [ \ break add* ] unless ;
: walk ( quot -- ) add-breakpoint call ; : (step-into-quot) ( quot -- ) add-breakpoint call ;
: (step-into-if) ? walk ; : (step-into-if) ? (step-into-quot) ;
: (step-into-dispatch) nth walk ; : (step-into-dispatch) nth (step-into-quot) ;
: (step-into-execute) ( word -- ) : (step-into-execute) ( word -- )
dup "step-into" word-prop [ dup "step-into" word-prop [
@ -48,7 +51,7 @@ SYMBOL: walking-thread
dup primitive? [ dup primitive? [
execute break execute break
] [ ] [
word-def walk word-def (step-into-quot)
] if ] if
] ?if ; ] ?if ;
@ -104,8 +107,8 @@ SYMBOL: +detached+
[ nip \ break add ] change-frame ; [ nip \ break add ] change-frame ;
{ {
{ call [ walk ] } { call [ (step-into-quot) ] }
{ (throw) [ drop walk ] } { (throw) [ drop (step-into-quot) ] }
{ execute [ (step-into-execute) ] } { execute [ (step-into-execute) ] }
{ if [ (step-into-if) ] } { if [ (step-into-if) ] }
{ dispatch [ (step-into-dispatch) ] } { dispatch [ (step-into-dispatch) ] }