| ' (s") A, ' c-s" A, |
' (s") A, ' c-s" A, |
| ' (.") A, ' c-." A, |
' (.") A, ' c-." A, |
| ' "lit A, ' c-c" A, |
' "lit A, ' c-c" A, |
| ' leave A, ' c-leave A, |
comp' leave drop A, ' c-leave A, |
| ' ?leave A, ' c-?leave A, |
comp' ?leave drop A, ' c-?leave A, |
| ' (do) A, ' c-do A, |
' (do) A, ' c-do A, |
| ' (?do) A, ' c-?do A, |
' (?do) A, ' c-?do A, |
| ' (for) A, ' c-for A, |
' (for) A, ' c-for A, |
| c-stop @ |
c-stop @ |
| UNTIL drop ; |
UNTIL drop ; |
| |
|
| DEFER dosee |
Defer xt-see-xt ( xt -- ) |
| |
\ this one is just a forward declaration for indirect recursion |
| |
|
| : dopri .name ." is primitive" cr ; |
: .defname ( xt c-addr u -- ) |
| : dovar ." Variable " .name cr ; |
rot look |
| : douse ." User " .name cr ; |
if ( c-addr u nfa ) |
| : docon dup ((name>)) >body @ . ." Constant " .name cr ; |
-rot type space .name |
| : doval dup ((name>)) >body @ . ." Value " .name cr ; |
else |
| : dodef ." Defer " dup >r .name cr |
drop ." noname " type |
| r@ ((name>)) >body @ look |
then |
| 0= ABORT" SEE: No valid xt in deferred word" |
space ; |
| dup dosee cr |
|
| ." ' " .name r> ." IS " .name cr ; |
Defer discode ( addr -- ) |
| : dodoe ." Create " dup .name cr |
\ hook for the disassembler: disassemble code at addr (as far as the |
| S" DOES> " Com# .string XPos @ Level ! name>int |
\ disassembler thinks is sensible) |
| >does-code dup C-Pass @ DebugMode = IF ScanMode c-pass ! EXIT THEN |
:noname ( addr -- ) |
| ScanMode c-pass ! dup makepass |
drop ." ..." ; |
| DisplayMode c-pass ! makepass ; |
IS discode |
| : doali here @ .name ." Alias " .name cr |
|
| here @ dosee ; |
: seecode ( xt -- ) |
| : docol |
dup s" Code" .defname |
| S" : " Com# .string |
>body discode |
| dup name>string 2 pick wordinfo .string bl cemit bl cemit |
." end-code" cr ; |
| ( XPos @ ) 2 Level ! |
: seevar ( xt -- ) |
| name>int >body |
s" Variable" .defname cr ; |
| C-Pass @ DebugMode = |
: seeuser ( xt -- ) |
| IF |
s" User" .defname cr ; |
| ScanMode c-pass ! EXIT |
: seecon ( xt -- ) |
| |
dup >body ? |
| |
s" Constant" .defname cr ; |
| |
: seevalue ( xt -- ) |
| |
dup >body ? |
| |
s" Value" .defname cr ; |
| |
: seedefer ( xt -- ) |
| |
dup >body @ xt-see-xt cr |
| |
dup s" Defer" .defname cr |
| |
>name dup ??? = if |
| |
drop ." lastxt >body !" |
| |
else |
| |
." IS " .name cr |
| |
then ; |
| |
: see-threaded ( addr -- ) |
| |
C-Pass @ DebugMode = IF |
| |
ScanMode c-pass ! |
| |
EXIT |
| THEN |
THEN |
| ScanMode c-pass ! dup makepass |
ScanMode c-pass ! dup makepass |
| DisplayMode c-pass ! makepass ; |
DisplayMode c-pass ! makepass ; |
| |
: seedoes ( xt -- ) |
| |
dup s" create" .defname cr |
| |
S" DOES> " Com# .string XPos @ Level ! |
| |
>does-code see-threaded ; |
| |
: seecol ( xt -- ) |
| |
dup s" :" .defname cr |
| |
2 Level ! |
| |
>body see-threaded ; |
| |
: seefield ( xt -- ) |
| |
dup >body ." 0 " ? ." 0 0 " |
| |
s" Field" .defname cr ; |
| |
|
| create wordtypes |
: xt-see ( xt -- ) |
| Pri# , ' dopri A, |
|
| Var# , ' dovar A, |
|
| Con# , ' docon A, |
|
| Val# , ' doval A, |
|
| Def# , ' dodef A, |
|
| Doe# , ' dodoe A, |
|
| Ali# , ' doali A, |
|
| Col# , ' docol A, |
|
| Use# , ' douse A, |
|
| 0 , |
|
| |
|
| : (dosee) ( lfa -- ) |
|
| dup dup cell+ c@ >r |
|
| wordinfo |
|
| wordtypes |
|
| BEGIN dup @ dup |
|
| WHILE 2 pick = IF cell+ @ nip EXECUTE |
|
| r> dup immediate-mask and IF ." immediate" THEN |
|
| restrict-mask and IF ." restrict" THEN |
|
| EXIT THEN |
|
| 2 cells + |
|
| REPEAT |
|
| 2drop rdrop |
|
| .name ." Don't know how to handle" cr ; |
|
| |
|
| ' (dosee) IS dosee |
|
| |
|
| : xtc ( xt -- ) \ do see at xt |
|
| Look 0= ABORT" SEE: No valid XT" |
|
| cr c-init |
cr c-init |
| dosee ; |
dup >does-code |
| |
if |
| |
seedoes EXIT |
| |
then |
| |
dup forthstart u< |
| |
if |
| |
seecode EXIT |
| |
then |
| |
dup >code-address |
| |
CASE |
| |
docon: of seecon endof |
| |
docol: of seecol endof |
| |
dovar: of seevar endof |
| |
douser: of seeuser endof |
| |
dodefer: of seedefer endof |
| |
dofield: of seefield endof |
| |
over >body of seecode endof |
| |
2drop abort" unknown word type" |
| |
ENDCASE ; |
| |
|
| |
: (xt-see-xt) ( xt -- ) |
| |
xt-see cr ." lastxt" ; |
| |
' (xt-see-xt) is xt-see-xt |
| |
|
| |
: (.immediate) ( xt -- ) |
| |
['] execute = if |
| |
." immediate" |
| |
then ; |
| |
|
| |
: name-see ( nfa -- ) |
| |
dup name>int >r |
| |
dup name>comp |
| |
over r@ = |
| |
if \ normal or immediate word |
| |
swap xt-see (.immediate) |
| |
else |
| |
r@ ['] compile-only-error = |
| |
if \ compile-only word |
| |
swap xt-see (.immediate) ." compile-only" |
| |
else \ interpret/compile word |
| |
r@ xt-see-xt cr |
| |
swap xt-see-xt cr |
| |
." interpret/compile " over .name (.immediate) |
| |
then |
| |
then |
| |
rdrop drop ; |
| |
|
| : see ( "name" -- ) \ tools |
: see ( "name" -- ) \ tools |
| name find-name dup 0= |
name find-name dup 0= |
| IF |
IF |
| drop -&13 bounce |
drop -&13 bounce |
| THEN |
THEN |
| name>int xtc ; |
name-see ; |
| |
|
| : lfc cr c-init cell+ dosee ; |
|
| : nfc cr c-init dosee ; |
|
| |
|
| |
|