Removing old tty walker
parent
e907f97f5b
commit
eca6b6b9be
|
@ -27,10 +27,6 @@ $terpri
|
|||
"! And by the way, comments look like this"
|
||||
"( Or like this )"
|
||||
}
|
||||
{ $curious
|
||||
"You can step through the execution of the above code interactively by clicking below:"
|
||||
{ $code "[ 10 sq 5 - . ] walk" }
|
||||
}
|
||||
{ $references
|
||||
{ "Factor's syntax can be extended, the parser can be called reflectively, and the " { $link . } " word is in fact a general facility for turning almost any object into a form which can be parsed back in again. If this interests you, consult the following sections:" }
|
||||
"syntax"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
USING: errors help image inspector io kernel listener memory
|
||||
modules parser prettyprint sequences test walker words ;
|
||||
modules parser prettyprint sequences test words ;
|
||||
|
||||
ARTICLE: "tools" "Development tools"
|
||||
"This section covers words which are used during development, and not usually invoked directly by user code."
|
||||
|
@ -9,7 +9,6 @@ $terpri
|
|||
{ $subsection "debugger" }
|
||||
{ $subsection "word-introspection" }
|
||||
{ $subsection "inspector" }
|
||||
{ $subsection "walker" }
|
||||
{ $subsection "annotations" }
|
||||
"Working on a project:"
|
||||
{ $subsection "sources" }
|
||||
|
@ -123,26 +122,6 @@ ARTICLE: "word-introspection" "Word introspection"
|
|||
"Display callers of a given word:"
|
||||
{ $subsection usage. } ;
|
||||
|
||||
ARTICLE: "walker" "The single stepper"
|
||||
"The single stepper evaluates a quotation a word at a time, offering the ability to look at stacks at any stage."
|
||||
$terpri
|
||||
"Single stepping is inititated by passing a quotation to a combinator:"
|
||||
{ $subsection walk }
|
||||
"The single stepper spawns a nested listener. You can exit the nested listener using " { $link bye } "; this resumes execution of the quotation."
|
||||
$terpri
|
||||
"The following words advance the single stepper; the latter recursively descends into compound definitions:"
|
||||
{ $subsection step }
|
||||
{ $subsection into }
|
||||
"At any point you can look at stacks and variables in the single stepper execution context:"
|
||||
{ $subsection &s }
|
||||
{ $subsection &r }
|
||||
{ $subsection &c }
|
||||
{ $subsection &get }
|
||||
"You can annotate a word with a breakpoint, so that the single stepper is started every time the word is called. See " { $link "annotations" } "."
|
||||
$terpri
|
||||
"An example to try out in the single stepper:"
|
||||
{ $code "[ { 3 1 2 } reverse first3 * swap - ] walk" } ;
|
||||
|
||||
ARTICLE: "unit-test" "Unit testing code"
|
||||
"A unit test is a piece of code which starts with known input values, then compares the output of a word with an expected output, where the expected output is defined by the word's contract."
|
||||
$terpri
|
||||
|
|
|
@ -111,7 +111,6 @@ sequences vectors words ;
|
|||
"/library/tools/memory.factor"
|
||||
"/library/tools/listener.factor"
|
||||
"/library/tools/inspector.factor"
|
||||
"/library/tools/walker.factor"
|
||||
"/library/tools/word-tools.factor"
|
||||
|
||||
"/library/test/test.factor"
|
||||
|
@ -295,7 +294,6 @@ sequences vectors words ;
|
|||
"/library/tools/inspector.facts"
|
||||
"/library/tools/listener.facts"
|
||||
"/library/tools/memory.facts"
|
||||
"/library/tools/walker.facts"
|
||||
|
||||
"/doc/handbook/alien.facts"
|
||||
"/doc/handbook/changes.facts"
|
||||
|
|
|
@ -95,7 +95,7 @@ global [
|
|||
"inspector" "io" "jedit" "kernel" "listener" "math"
|
||||
"memory" "modules" "namespaces" "parser" "prettyprint"
|
||||
"sequences" "shells" "strings" "styles" "test"
|
||||
"threads" "vectors" "walker" "words"
|
||||
"threads" "vectors" "words"
|
||||
} set-use
|
||||
"scratchpad" set-in
|
||||
] bind
|
||||
|
|
|
@ -91,7 +91,9 @@ DEFER: describe
|
|||
|
||||
: callframe. ( seq pos -- )
|
||||
[
|
||||
hilite-index set dup hilite-quotation set .
|
||||
hilite-index set dup hilite-quotation set
|
||||
1 nesting-limit set
|
||||
.
|
||||
] with-scope ;
|
||||
|
||||
: callstack. ( seq -- seq )
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
! Copyright (C) 2004, 2006 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
IN: interpreter
|
||||
USING: errors generic io kernel kernel-internals math
|
||||
namespaces prettyprint sequences strings vectors words ;
|
||||
USING: errors generic io kernel kernel-internals math namespaces
|
||||
prettyprint sequences strings threads vectors words ;
|
||||
|
||||
! A Factor interpreter written in Factor. It can transfer the
|
||||
! continuation to and from the primary interpreter. Used by
|
||||
|
@ -52,7 +52,7 @@ SYMBOL: callframe-end
|
|||
|
||||
: next ( quot -- obj )
|
||||
{
|
||||
{ [ done? ] [ drop f (meta-call) ] }
|
||||
{ [ done? ] [ drop [ ] (meta-call) ] }
|
||||
{ [ done-cf? ] [ drop up ] }
|
||||
{ [ t ] [ >r (next) r> call ] }
|
||||
} cond ; inline
|
||||
|
@ -87,14 +87,28 @@ SYMBOL: callframe-end
|
|||
#! Note we do tail call optimization here.
|
||||
save-callframe (meta-call) ;
|
||||
|
||||
: host-word ( word -- )
|
||||
: (host-quot) ( n quot -- )
|
||||
[
|
||||
[
|
||||
swap , \ continuation , , \ continue-with ,
|
||||
] [ ] make dup push-c 0 push-c length push-c
|
||||
[ \ continuation , , \ continue-with , ] [ ] make
|
||||
append
|
||||
dup push-c swap push-c length push-c
|
||||
meta-interp continue
|
||||
] callcc1 set-meta-interp drop ;
|
||||
|
||||
: host-quot ( quot -- ) 0 swap (host-quot) ;
|
||||
|
||||
: host-word ( word -- ) unit host-quot ;
|
||||
|
||||
: end-quot ( -- )
|
||||
callframe-scan get callframe get (host-quot) [ ] (meta-call) ;
|
||||
|
||||
: end ( -- )
|
||||
save-callframe
|
||||
meta-c [ V{ [ stop ] 0 1 } swap append ] change
|
||||
meta-interp schedule-thread yield
|
||||
V{ } clone meta-c set
|
||||
[ ] (meta-call) ;
|
||||
|
||||
GENERIC: do-1 ( object -- )
|
||||
|
||||
M: word do-1 ( word -- )
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
! See http://factor.sf.net/license.txt for BSD license.
|
||||
IN: jedit
|
||||
USING: arrays errors io kernel listener math namespaces
|
||||
parser prettyprint sequences strings words ;
|
||||
parser prettyprint sequences strings words shells ;
|
||||
|
||||
! Some words to send requests to a running jEdit instance to
|
||||
! edit files and position the cursor on a specific line number.
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
! Copyright (C) 2004, 2005 Slava Pestov.
|
||||
! See http://factor.sf.net/license.txt for BSD license.
|
||||
IN: walker
|
||||
USING: errors hashtables inspector interpreter io kernel
|
||||
listener math namespaces prettyprint sequences strings
|
||||
vectors words ;
|
||||
|
||||
: &s ( -- ) meta-d get stack. ;
|
||||
|
||||
: &r ( -- ) meta-r get stack. ;
|
||||
|
||||
: meta-c* ( -- seq ) meta-c get meta-callframe append ;
|
||||
|
||||
: &c ( -- ) meta-c* callstack. ;
|
||||
|
||||
: &get ( var -- value ) meta-name get hash-stack ;
|
||||
|
||||
: report ( -- ) callframe get callframe-scan get callframe. ;
|
||||
|
||||
: step ( -- ) next do-1 report ;
|
||||
|
||||
: into ( -- ) next do report ;
|
||||
|
||||
: end-walk ( -- )
|
||||
save-callframe meta-interp continue ;
|
||||
|
||||
: walk-banner ( -- )
|
||||
"&s &r &c show stepper stacks" print
|
||||
"&get ( var -- value ) get stepper variable value" print
|
||||
"step -- single step over" print
|
||||
"into -- single step into" print
|
||||
"bye -- continue execution" print
|
||||
report ;
|
||||
|
||||
: set-walk-hooks ( -- )
|
||||
[ meta-d get ] datastack-hook set
|
||||
"walk " listener-prompt set ;
|
||||
|
||||
: walk ( quot -- )
|
||||
continuation [
|
||||
set-meta-interp pop-d drop (meta-call)
|
||||
set-walk-hooks walk-banner (listener) end-walk
|
||||
] with-scope ;
|
|
@ -1,35 +0,0 @@
|
|||
IN: walker
|
||||
USING: help inspector ;
|
||||
|
||||
HELP: &s "( -- )"
|
||||
{ $description "Prints the single stepper data stack." }
|
||||
{ $notes "This is analogous to " { $link .s } "." } ;
|
||||
|
||||
HELP: &r "( -- )"
|
||||
{ $description "Prints the single stepper retain stack." }
|
||||
{ $notes "This is analogous to " { $link .r } "." } ;
|
||||
|
||||
HELP: &c "( -- )"
|
||||
{ $description "Prints the single stepper call stack and the currently executing quotation." }
|
||||
{ $notes "This is analogous to " { $link .c } "." } ;
|
||||
|
||||
HELP: &get "( var -- value )"
|
||||
{ $values { "var" "an object" } { "value" "an object" } }
|
||||
{ $description "Looks up a variable value in the single stepper name stack." } ;
|
||||
|
||||
HELP: report "( -- )"
|
||||
{ $description "Print the quotation currently executing in the single stepper." } ;
|
||||
|
||||
HELP: step "( -- )"
|
||||
{ $description "Run one iteration of the single stepper, without stepping into compound definitions." }
|
||||
{ $see-also into } ;
|
||||
|
||||
HELP: into "( -- )"
|
||||
{ $description "Run one iteration of the single stepper; if the current word is a compound definition, the single stepper begins stepping through the word's definition." }
|
||||
{ $see-also step } ;
|
||||
|
||||
HELP: end-walk "( -- )"
|
||||
{ $description "Continue normal execution of the single-stepped quotation." } ;
|
||||
|
||||
HELP: walk "( quot -- )"
|
||||
{ $description "Spawn a new listener, customized for single-stepping through a quotation using the " { $link step } " and " { $link into } " words. The state of the single stepper stacks can be displayed using " { $link &s } ", " { $link &r } " and " { $link &c } ", while variable values can be inspected with " { $link &get } "." } ;
|
|
@ -2,7 +2,7 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
IN: words
|
||||
USING: help inspector io kernel math namespaces prettyprint
|
||||
sequences strings walker ;
|
||||
sequences strings ;
|
||||
|
||||
: word-outliner ( word quot -- )
|
||||
swap natural-sort [
|
||||
|
@ -32,12 +32,5 @@ sequences strings walker ;
|
|||
|
||||
: watch ( word -- ) [ (watch) ] annotate ;
|
||||
|
||||
: break ( word -- ) [ nip [ walk ] curry ] annotate ;
|
||||
|
||||
: break-on ( word test -- | test: -- ? )
|
||||
swap [
|
||||
nip [ swap % dup [ walk ] curry , , \ if , ] [ ] make
|
||||
] annotate ;
|
||||
|
||||
: profile ( word -- )
|
||||
[ swap [ global [ inc ] bind ] curry swap append ] annotate ;
|
||||
|
|
|
@ -20,14 +20,6 @@ HELP: watch "( word -- )"
|
|||
{ $values { "word" "a word" } }
|
||||
{ $description "Changes a word definition so that a message together with the stack contents is output before and after the word runs." } ;
|
||||
|
||||
HELP: break "( word -- )"
|
||||
{ $values { "word" "a word" } }
|
||||
{ $description "Changes a word definition so that it runs in the single stepper. See " { $link "walker" } "." } ;
|
||||
|
||||
HELP: break-on "( word quot -- )"
|
||||
{ $values { "word" "a word" } { "quot" "a quotation with stack effect " { $snippet "( -- ? )" } } }
|
||||
{ $description "Changes a word definition so that the quotation runs first, and if it outputs a true value, the word runs in the single stepper. See " { $link "walker" } "." } ;
|
||||
|
||||
HELP: profile "( word -- )"
|
||||
{ $values { "word" "a word" } }
|
||||
{ $description "Changes a word definition so the variable named by the word in the global namespace is incremented every time the word is executed." } ;
|
||||
|
|
Loading…
Reference in New Issue