File:  [gforth] / gforth / see.fs
Revision 1.34: download - view: text, annotated - select for diffs
Sun Jan 28 17:39:33 2001 UTC (20 years, 1 month ago) by anton
Branches: MAIN
CVS tags: HEAD
SEE bugfix (coming from long names)
NEXTNAME bugfix (but still length restrictions)

    1: \ SEE.FS       highend SEE for ANSforth                16may93jaw
    2: 
    3: \ Copyright (C) 1995,2000 Free Software Foundation, Inc.
    4: 
    5: \ This file is part of Gforth.
    6: 
    7: \ Gforth is free software; you can redistribute it and/or
    8: \ modify it under the terms of the GNU General Public License
    9: \ as published by the Free Software Foundation; either version 2
   10: \ of the License, or (at your option) any later version.
   11: 
   12: \ This program is distributed in the hope that it will be useful,
   13: \ but WITHOUT ANY WARRANTY; without even the implied warranty of
   14: \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   15: \ GNU General Public License for more details.
   16: 
   17: \ You should have received a copy of the GNU General Public License
   18: \ along with this program; if not, write to the Free Software
   19: \ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
   20: 
   21: 
   22: \ May be cross-compiled
   23: 
   24: \ I'm sorry. This is really not "forthy" enough.
   25: 
   26: \ Ideas:        Level should be a stack
   27: 
   28: require look.fs
   29: require termsize.fs
   30: require wordinfo.fs
   31: [IFUNDEF] .name
   32: : id. ( nt -- ) \ gforth
   33:     \G Print the name of the word represented by @var{nt}.
   34:     \ this name comes from fig-Forth
   35:     name>string type space ;
   36: 
   37: ' id. alias .id ( nt -- )
   38: \G F83 name for @code{id.}.
   39: 
   40: ' id. alias .name ( nt -- )
   41: \G Gforth <=0.5.0 name for @code{id.}.
   42: 
   43: [THEN]
   44: 
   45: decimal
   46: 
   47: \ Screen format words                                   16may93jaw
   48: 
   49: VARIABLE C-Output   1 C-Output  !
   50: VARIABLE C-Formated 1 C-Formated !
   51: VARIABLE C-Highlight 0 C-Highlight !
   52: VARIABLE C-Clearline 0 C-Clearline !
   53: 
   54: VARIABLE XPos
   55: VARIABLE YPos
   56: VARIABLE Level
   57: 
   58: : Format        C-Formated @ C-Output @ and
   59:                 IF dup spaces XPos +! ELSE drop THEN ;
   60: 
   61: : level+        7 Level +!
   62:                 Level @ XPos @ -
   63:                 dup 0> IF Format ELSE drop THEN ;
   64: 
   65: : level-        -7 Level +! ;
   66: 
   67: VARIABLE nlflag
   68: VARIABLE uppercase	\ structure words are in uppercase
   69: 
   70: DEFER nlcount ' noop IS nlcount
   71: 
   72: : nl            nlflag on ;
   73: : (nl)          nlcount
   74:                 XPos @ Level @ = IF EXIT THEN \ ?Exit
   75:                 C-Formated @ IF
   76:                 C-Output @
   77:                 IF C-Clearline @ IF cols XPos @ - spaces
   78:                                  ELSE cr THEN
   79:                 1 YPos +! 0 XPos !
   80:                 Level @ spaces
   81:                 THEN Level @ XPos ! THEN ;
   82: 
   83: : warp?         ( len -- len )
   84:                 nlflag @ IF (nl) nlflag off THEN
   85:                 XPos @ over + cols u>= IF (nl) THEN ;
   86: 
   87: : c-to-upper ( c1 -- c2 ) \ gforth
   88:     \ nac05feb1999 there is a primitive, toupper, with this function
   89:     dup [char] a >= over [char] z <= and if  bl -  then ;
   90: 
   91: : ctype         ( adr len -- )
   92:                 warp? dup XPos +! C-Output @ 
   93: 		IF uppercase @ IF bounds ?DO i c@ c-to-upper emit LOOP
   94: 				  uppercase off ELSE type THEN
   95: 		ELSE 2drop THEN ;
   96: 
   97: : cemit         1 warp?
   98:                 over bl = Level @ XPos @ = and
   99:                 IF 2drop ELSE XPos +! C-Output @ IF emit ELSE drop THEN
  100:                 THEN ;
  101: 
  102: DEFER .string ( c-addr u n -- )
  103: 
  104: [IFDEF] Green
  105: VARIABLE Colors Colors on
  106: 
  107: : (.string)     ( c-addr u n -- )
  108:                 over warp? drop
  109:                 Colors @
  110:                 IF C-Highlight @ ?dup
  111:                    IF   CT@ swap CT@ or
  112:                    ELSE CT@
  113:                    THEN
  114:                 attr! ELSE drop THEN
  115:                 ctype  ct @ attr! ;
  116: [ELSE]
  117: : (.string)     ( c-addr u n -- )
  118:                 drop ctype ;
  119: [THEN]
  120: 
  121: ' (.string) IS .string
  122: 
  123: 
  124: : .struc        
  125: 	uppercase on Str# .string ;
  126: 
  127: \ CODES (Branchtypes)                                    15may93jaw
  128: 
  129: 21 CONSTANT RepeatCode
  130: 22 CONSTANT AgainCode
  131: 23 CONSTANT UntilCode
  132: \ 09 CONSTANT WhileCode
  133: 10 CONSTANT ElseCode
  134: 11 CONSTANT AheadCode
  135: 13 CONSTANT WhileCode2
  136: 14 CONSTANT Disable
  137: 15 CONSTANT LeaveCode
  138: 
  139: 
  140: \ FORMAT WORDS                                          13jun93jaw
  141: 
  142: VARIABLE C-Stop
  143: VARIABLE Branches
  144: 
  145: VARIABLE BranchPointer	\ point to the end of branch table
  146: VARIABLE SearchPointer
  147: 
  148: \ The branchtable consists of three entrys:
  149: \ address of branch , branch destination , branch type
  150: 
  151: CREATE BranchTable 128 cells allot
  152: here 3 cells -
  153: ACONSTANT MaxTable
  154: 
  155: : FirstBranch BranchTable cell+ SearchPointer ! ;
  156: 
  157: : (BranchAddr?) ( a-addr1 -- a-addr2 true | false )
  158: \ searches a branch with destination a-addr1
  159: \ a-addr1: branch destination
  160: \ a-addr2: pointer in branch table
  161:         SearchPointer @
  162:         BEGIN   dup BranchPointer @ u<
  163:         WHILE
  164:                 dup @ 2 pick <>
  165:         WHILE   3 cells +
  166:         REPEAT
  167:         nip dup  3 cells + SearchPointer ! true
  168:         ELSE
  169:         2drop false
  170:         THEN ;
  171: 
  172: : BranchAddr?
  173:         FirstBranch (BranchAddr?) ;
  174: 
  175: ' (BranchAddr?) ALIAS MoreBranchAddr?
  176: 
  177: : CheckEnd ( a-addr -- true | false )
  178:         BranchTable cell+
  179:         BEGIN   dup BranchPointer @ u<
  180:         WHILE
  181:                 dup @ 2 pick u<=
  182:         WHILE   3 cells +
  183:         REPEAT
  184:         2drop false
  185:         ELSE
  186:         2drop true
  187:         THEN ;
  188: 
  189: : MyBranch      ( a-addr -- a-addr a-addr2 )
  190: \ finds branch table entry for branch at a-addr
  191:                 dup @ over +
  192:                 BranchAddr?
  193:                 BEGIN
  194:                 WHILE 1 cells - @
  195:                       over <>
  196:                 WHILE dup @ over +
  197:                       MoreBranchAddr?
  198:                 REPEAT
  199:                 SearchPointer @ 3 cells -
  200:                 ELSE    true ABORT" SEE: Table failure"
  201:                 THEN ;
  202: 
  203: \
  204: \                 addrw               addrt
  205: \       BEGIN ... WHILE ... AGAIN ... THEN
  206: \         ^         !        !          ^
  207: \         ----------+--------+          !
  208: \                   !                   !
  209: \                   +-------------------+
  210: \
  211: \
  212: 
  213: : CheckWhile ( a-addrw a-addrt -- true | false )
  214:         BranchTable
  215:         BEGIN   dup BranchPointer @ u<
  216:         WHILE   dup @ 3 pick u>
  217:                 over @ 3 pick u< and
  218:                 IF dup cell+ @ 3 pick u<
  219:                         IF 2drop drop true EXIT THEN
  220:                 THEN
  221:                 3 cells +
  222:         REPEAT
  223:         2drop drop false ;
  224: 
  225: : ,Branch ( a-addr -- )
  226:         BranchPointer @ dup MaxTable u> ABORT" SEE: Table overflow"
  227:         !
  228:         1 cells BranchPointer +! ;
  229: 
  230: : Type!   ( u -- )
  231:         BranchPointer @ 1 cells - ! ;
  232: 
  233: : Branch! ( a-addr rel -- a-addr )
  234:         over + over ,Branch ,Branch 0 ,Branch ;
  235: 
  236: \ DEFER CheckUntil
  237: VARIABLE NoOutput
  238: VARIABLE C-Pass
  239: 
  240: 0 CONSTANT ScanMode
  241: 1 CONSTANT DisplayMode
  242: 2 CONSTANT DebugMode
  243: 
  244: : Scan? ( -- flag ) C-Pass @ 0= ;
  245: : Display? ( -- flag ) C-Pass @ 1 = ;
  246: : Debug? ( -- flag ) C-Pass @ 2 = ;
  247: 
  248: : back? ( n -- flag ) 0< ;
  249: : ahead? ( n -- flag ) 0> ;
  250: 
  251: : c-lit
  252:     Display? IF
  253: 	dup @ dup abs 0 <# #S rot sign #> 0 .string bl cemit
  254:     THEN
  255:     cell+ ;
  256: 
  257: : .name-without ( addr -- addr )
  258: \ prints a name without () e.g. (+LOOP) or (s")
  259:   dup 1 cells - @ look 
  260:   IF   name>string over c@ '( = IF 1 /string THEN
  261:        2dup + 1- c@ ') = IF 1- THEN .struc ELSE drop 
  262:   THEN ;
  263: 
  264: : c-c"
  265: 	Display? IF nl .name-without THEN
  266:         count 2dup + aligned -rot
  267:         Display?
  268:         IF      bl cemit 0 .string
  269:                 [char] " cemit bl cemit
  270:         ELSE    2drop
  271:         THEN ;
  272: 
  273: 
  274: : Forward? ( a-addr true | false -- a-addr true | false )
  275: \ a-addr1 is pointer into branch table
  276: \ returns true when jump is a forward jump
  277:         IF      dup dup @ swap 1 cells - @ -
  278:                 Ahead? IF true ELSE drop false THEN
  279:                 \ only if forward jump
  280:         ELSE    false THEN ;
  281: 
  282: : RepeatCheck ( a-addr1 a-addr2 true | false -- false )
  283:         IF  BEGIN  2dup
  284:                    1 cells - @ swap dup @ +
  285:                    u<=
  286:             WHILE  drop dup cell+
  287:                    MoreBranchAddr? 0=
  288:             UNTIL  false
  289:             ELSE   true
  290:             THEN
  291:         ELSE false
  292:         THEN ;
  293: 
  294: : c-branch
  295:         Scan?
  296:         IF      dup @ Branch!
  297:                 dup @ back?
  298:                 IF                      \ might be: AGAIN, REPEAT
  299:                         dup cell+ BranchAddr? Forward?
  300:                         RepeatCheck
  301:                         IF      RepeatCode Type!
  302:                                 cell+ Disable swap !
  303:                         ELSE    AgainCode Type!
  304:                         THEN
  305:                 ELSE    dup cell+ BranchAddr? Forward?
  306:                         IF      ElseCode Type! drop
  307:                         ELSE    AheadCode Type!
  308:                         THEN
  309:                 THEN
  310:         THEN
  311:         Display?
  312:         IF
  313:                 dup @ back?
  314:                 IF                      \ might be: AGAIN, REPEAT
  315:                         level- nl
  316:                         dup cell+ BranchAddr? Forward?
  317:                         RepeatCheck
  318:                         IF      drop S" REPEAT " .struc nl
  319:                         ELSE    S" AGAIN " .struc nl
  320:                         THEN
  321:                 ELSE    MyBranch cell+ @ LeaveCode =
  322: 			IF 	S" LEAVE " .struc
  323: 			ELSE
  324: 				dup cell+ BranchAddr? Forward?
  325:        	                 	IF      dup cell+ @ WhileCode2 =
  326:        	                         	IF nl S" ELSE" .struc level+
  327:                                 	ELSE level- nl S" ELSE" .struc level+ THEN
  328:                                 	cell+ Disable swap !
  329:                         	ELSE    S" AHEAD" .struc level+
  330:                         	THEN
  331: 			THEN
  332:                 THEN
  333:         THEN
  334:         Debug?
  335:         IF      dup @ +
  336:         ELSE    cell+
  337:         THEN ;
  338: 
  339: : DebugBranch
  340:         Debug?
  341:         IF      dup @ over + swap THEN ; \ return 2 different addresses
  342: 
  343: : c-?branch
  344:         Scan?
  345:         IF      dup @ Branch!
  346:                 dup @ Back?
  347:                 IF      UntilCode Type! THEN
  348:         THEN
  349:         Display?
  350:         IF      dup @ Back?
  351:                 IF      level- nl S" UNTIL " .struc nl
  352:                 ELSE    dup    dup @ over +
  353:                         CheckWhile
  354:                         IF      MyBranch
  355:                                 cell+ dup @ 0=
  356:                                          IF WhileCode2 swap !
  357:                                          ELSE drop THEN
  358:                                 level- nl
  359:                                 S" WHILE " .struc
  360:                                 level+
  361:                         ELSE    MyBranch cell+ @ LeaveCode =
  362: 				IF   s" 0= ?LEAVE " .struc
  363: 				ELSE nl S" IF " .struc level+
  364: 				THEN
  365:                         THEN
  366:                 THEN
  367:         THEN
  368:         DebugBranch
  369:         cell+ ;
  370: 
  371: : c-for
  372:         Display? IF nl S" FOR" .struc level+ THEN ;
  373: 
  374: : c-loop
  375:         Display? IF level- nl .name-without bl cemit nl THEN
  376:         DebugBranch cell+ 
  377: 	Scan? 
  378: 	IF 	dup BranchAddr? 
  379: 		BEGIN   WHILE cell+ LeaveCode swap !
  380: 			dup MoreBranchAddr?
  381: 		REPEAT
  382: 	THEN
  383: 	cell+ ;
  384: 
  385: : c-do
  386:         Display? IF nl .name-without level+ THEN ;
  387: 
  388: : c-?do
  389:         Display? IF nl S" ?DO" .struc level+ THEN
  390:         DebugBranch cell+ ;
  391: 
  392: : c-exit  dup 1 cells -
  393:         CheckEnd
  394:         IF      Display? IF nlflag off S" ;" Com# .string THEN
  395:                 C-Stop on
  396:         ELSE    Display? IF S" EXIT " .struc THEN
  397:         THEN
  398:         Debug? IF drop THEN ;
  399: 
  400: : c-abort"
  401:         count 2dup + aligned -rot
  402:         Display?
  403:         IF      S" ABORT" .struc
  404:                 [char] " cemit bl cemit 0 .string
  405:                 [char] " cemit bl cemit
  406:         ELSE    2drop
  407:         THEN ;
  408: 
  409: [IFDEF] (does>)
  410: : c-does>               \ end of create part
  411:         Display? IF S" DOES> " Com# .string THEN
  412: 	maxaligned /does-handler + ;
  413: [THEN]
  414: 
  415: [IFDEF] (compile)
  416: : c-(compile)
  417:     Display?
  418:     IF
  419: 	s" POSTPONE " Com# .string
  420: 	dup @ look 0= ABORT" SEE: No valid XT"
  421: 	name>string 0 .string bl cemit
  422:     THEN
  423:     cell+ ;
  424: [THEN]
  425: 
  426: CREATE C-Table
  427: 	        ' lit A,            ' c-lit A,
  428: 		' (s") A,	    ' c-c" A,
  429:        		 ' (.") A,	    ' c-c" A,
  430:         	' "lit A,           ' c-c" A,
  431: [IFDEF] (c")	' (c") A,	    ' c-c" A, [THEN]
  432:         	' (do) A,           ' c-do A,
  433: [IFDEF] (+do)	' (+do) A,	    ' c-do A, [THEN]
  434: [IFDEF] (u+do)	' (u+do) A,	    ' c-do A, [THEN]
  435: [IFDEF] (-do)	' (-do) A,	    ' c-do A, [THEN]
  436: [IFDEF] (u-do)	' (u-do) A,	    ' c-do A, [THEN]
  437:         	' (?do) A,          ' c-?do A,
  438:         	' (for) A,          ' c-for A,
  439:         	' ?branch A,        ' c-?branch A,
  440:         	' branch A,         ' c-branch A,
  441:         	' (loop) A,         ' c-loop A,
  442:         	' (+loop) A,        ' c-loop A,
  443: [IFDEF] (s+loop) ' (s+loop) A,       ' c-loop A, [THEN]
  444: [IFDEF] (-loop) ' (-loop) A,        ' c-loop A, [THEN]
  445:         	' (next) A,         ' c-loop A,
  446:         	' ;s A,             ' c-exit A,
  447:         	' (abort") A,       ' c-abort" A,
  448: \ only defined if compiler is loaded
  449: [IFDEF] (compile) ' (compile) A,      ' c-(compile) A, [THEN]
  450: [IFDEF] (does>) ' (does>) A,        ' c-does> A, [THEN]
  451:         	0 ,		here 0 ,
  452: 
  453: avariable c-extender
  454: c-extender !
  455: 
  456: \ DOTABLE                                               15may93jaw
  457: 
  458: : DoTable ( cfa -- flag )
  459:         C-Table
  460:         BEGIN   dup @ dup 0= 
  461: 		IF drop cell+ @ dup 
  462: 		  IF ( next table!) dup @ ELSE 
  463: 			( end!) 2drop false EXIT THEN 
  464: 		THEN
  465: 		\ jump over to extender, if any 26jan97jaw
  466:        		2 pick <>
  467:         WHILE   2 cells +
  468:         REPEAT
  469:         nip cell+ perform
  470:         true
  471: 	;
  472: 
  473: : BranchTo? ( a-addr -- a-addr )
  474:         Display?  IF    dup BranchAddr?
  475:                         IF
  476: 				BEGIN cell+ @ dup 20 u>
  477:                                 IF drop nl S" BEGIN " .struc level+
  478:                                 ELSE
  479:                                   dup Disable <> over LeaveCode <> and
  480:                                   IF   WhileCode2 =
  481:                                        IF nl S" THEN " .struc nl ELSE
  482:                                        level- nl S" THEN " .struc nl THEN
  483:                                   ELSE drop THEN
  484:                                 THEN
  485:                                   dup MoreBranchAddr? 0=
  486:                            UNTIL
  487:                         THEN
  488:                   THEN ;
  489: 
  490: : analyse ( a-addr1 -- a-addr2 )
  491:     Branches @ IF BranchTo? THEN
  492:     dup cell+ swap @
  493:     dup >r DoTable r> swap IF drop EXIT THEN
  494:     Display?
  495:     IF
  496: 	look 0= IF
  497: 	    drop dup 1 cells - @ ." <" 0 .r ." >"
  498: 	ELSE
  499: 	    dup cell+ @ immediate-mask and
  500: 	    IF
  501: 		bl cemit  ." POSTPONE "
  502: 	    THEN
  503: 	    dup name>string rot wordinfo .string
  504: 	THEN
  505: 	bl cemit
  506:     ELSE
  507: 	drop
  508:     THEN ;
  509: 
  510: : c-init
  511:         0 YPos ! 0 XPos !
  512:         0 Level ! nlflag off
  513:         BranchTable BranchPointer !
  514:         c-stop off
  515:         Branches on ;
  516: 
  517: : makepass ( a-addr -- )
  518:     c-stop off
  519:     BEGIN
  520: 	analyse
  521: 	c-stop @
  522:     UNTIL drop ;
  523: 
  524: Defer xt-see-xt ( xt -- )
  525: \ this one is just a forward declaration for indirect recursion
  526: 
  527: : .defname ( xt c-addr u -- )
  528:     rot look
  529:     if ( c-addr u nfa )
  530: 	-rot type space .name
  531:     else
  532: 	drop ." noname " type
  533:     then
  534:     space ;
  535: 
  536: Defer discode ( addr u -- ) \ gforth
  537: \G hook for the disassembler: disassemble code at addr of length u
  538: ' dump IS discode
  539: 
  540: : next-head ( addr1 -- addr2 ) \ gforth
  541:     \G find the next header starting after addr1, up to here (unreliable).
  542:     here swap u+do
  543: 	i head?
  544: 	if
  545: 	    i unloop exit
  546: 	then
  547:     cell +loop
  548:     here ;
  549: 
  550: : umin ( u1 u2 -- u )
  551:     2dup u>
  552:     if
  553: 	swap
  554:     then
  555:     drop ;
  556: 	
  557: : next-prim ( addr1 -- addr2 ) \ gforth
  558:     \G find the next primitive after addr1 (unreliable)
  559:     1+ >r -1 primstart
  560:     begin ( umin head R: boundary )
  561: 	@ dup
  562:     while
  563: 	tuck name>int >code-address ( head1 umin ca R: boundary )
  564: 	r@ - umin
  565: 	swap
  566:     repeat
  567:     drop dup r@ negate u>=
  568:     \ "umin+boundary within [0,boundary)" = "umin within [-boundary,0)"
  569:     if ( umin R: boundary ) \ no primitive found behind -> use a default length
  570: 	drop 31
  571:     then
  572:     r> + ;
  573: 
  574: : seecode ( xt -- )
  575:     dup s" Code" .defname
  576:     threading-method
  577:     if
  578: 	>code-address
  579:     then
  580:     dup in-dictionary? \ user-defined code word?
  581:     if
  582: 	dup next-head
  583:     else
  584: 	dup next-prim
  585:     then
  586:     over - discode
  587:     ." end-code" cr ;
  588: : seevar ( xt -- )
  589:     s" Variable" .defname cr ;
  590: : seeuser ( xt -- )
  591:     s" User" .defname cr ;
  592: : seecon ( xt -- )
  593:     dup >body ?
  594:     s" Constant" .defname cr ;
  595: : seevalue ( xt -- )
  596:     dup >body ?
  597:     s" Value" .defname cr ;
  598: : seedefer ( xt -- )
  599:     dup >body @ xt-see-xt cr
  600:     dup s" Defer" .defname cr
  601:     >name ?dup-if
  602: 	." IS " .name cr
  603:     else
  604: 	." lastxt >body !"
  605:     then ;
  606: : see-threaded ( addr -- )
  607:     C-Pass @ DebugMode = IF
  608: 	ScanMode c-pass !
  609: 	EXIT
  610:     THEN
  611:     ScanMode c-pass ! dup makepass
  612:     DisplayMode c-pass ! makepass ;
  613: : seedoes ( xt -- )
  614:     dup s" create" .defname cr
  615:     S" DOES> " Com# .string XPos @ Level !
  616:     >does-code see-threaded ;
  617: : seecol ( xt -- )
  618:     dup s" :" .defname nl
  619:     2 Level !
  620:     >body see-threaded ;
  621: : seefield ( xt -- )
  622:     dup >body ." 0 " ? ." 0 0 "
  623:     s" Field" .defname cr ;
  624: 
  625: : xt-see ( xt -- ) \ gforth
  626:     \G Decompile the definition represented by @i{xt}.
  627:     cr c-init
  628:     dup >does-code
  629:     if
  630: 	seedoes EXIT
  631:     then
  632:     dup xtprim?
  633:     if
  634: 	seecode EXIT
  635:     then
  636:     dup >code-address
  637:     CASE
  638: 	docon: of seecon endof
  639: 	docol: of seecol endof
  640: 	dovar: of seevar endof
  641: [ [IFDEF] douser: ]
  642: 	douser: of seeuser endof
  643: [ [THEN] ]
  644: [ [IFDEF] dodefer: ]
  645: 	dodefer: of seedefer endof
  646: [ [THEN] ]
  647: [ [IFDEF] dofield: ]
  648: 	dofield: of seefield endof
  649: [ [THEN] ]
  650: 	over       of seecode endof \ direct threaded code words
  651: 	over >body of seecode endof \ indirect threaded code words
  652: 	2drop abort" unknown word type"
  653:     ENDCASE ;
  654: 
  655: : (xt-see-xt) ( xt -- )
  656:     xt-see cr ." lastxt" ;
  657: ' (xt-see-xt) is xt-see-xt
  658: 
  659: : (.immediate) ( xt -- )
  660:     ['] execute = if
  661: 	."  immediate"
  662:     then ;
  663: 
  664: : name-see ( nfa -- )
  665:     dup name>int >r
  666:     dup name>comp 
  667:     over r@ =
  668:     if \ normal or immediate word
  669: 	swap xt-see (.immediate)
  670:     else
  671: 	r@ ['] compile-only-error =
  672: 	if \ compile-only word
  673: 	    swap xt-see (.immediate) ."  compile-only"
  674: 	else \ interpret/compile word
  675: 	    r@ xt-see-xt cr
  676: 	    swap xt-see-xt cr
  677: 	    ." interpret/compile " over .name (.immediate)
  678: 	then
  679:     then
  680:     rdrop drop ;
  681: 
  682: : see ( "<spaces>name" -- ) \ tools
  683:     \G Locate @var{name} using the current search order. Display the
  684:     \G definition of @var{name}. Since this is achieved by decompiling
  685:     \G the definition, the formatting is mechanised and some source
  686:     \G information (comments, interpreted sequences within definitions
  687:     \G etc.) is lost.
  688:     name find-name dup 0=
  689:     IF
  690: 	drop -&13 throw
  691:     THEN
  692:     name-see ;
  693: 
  694: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>