1 \ @(#) forget.fth 98/01/26 1.2
4 \ forget part of dictionary
7 \ Copyright 1994 3DO, Phil Burk, Larry Polansky, Devid Rosenboom
9 \ The pForth software code is dedicated to the public domain,
10 \ and any third party may reproduce, distribute and modify
11 \ the pForth software code or any derivative works thereof
12 \ without any compensation or license. The pForth software
13 \ code is provided on an "as is" basis without any warranty
14 \ of any kind, including, without limitation, the implied
15 \ warranties of merchantability and fitness for a particular
16 \ purpose and their equivalents under the laws of any jurisdiction.
18 \ 19970701 PLB Use unsigned compares for machines with "negative" addresses.
20 variable RFENCE \ relocatable value below which we won't forget
22 : FREEZE ( -- , protect below here )
26 : FORGET.NFA ( nfa -- , set DP etc. )
28 prevname ( dup current ! ) dup context ! n>nextlink headers-ptr !
31 : VERIFY.FORGET ( nfa -- , ask for verification if below fence )
32 dup name> >code rfence a@ u< \ 19970701
34 >newline dup id. ." is below fence!!" cr
40 : (FORGET) ( <name> -- )
43 ELSE ." FORGET - couldn't find " count type cr abort
47 variable LAST-FORGET \ contains address of last if.forgotten frame
50 : IF.FORGOTTEN ( <name> -- , place links in dictionary without header )
54 last-forget a@ a, \ Cell[0] = rel address of previous frame
55 last-forget a! \ point to this frame
56 compile, \ Cell[1] = xt for this frame
57 ELSE ." IF.FORGOTTEN - couldn't find " dup 9 dump cr count type cr abort
62 : [FORGET] ( <name> -- , forget then exec forgotten words )
65 BEGIN a@ dup 0<> \ 19970701
66 IF dup here u> \ 19970701
67 IF dup cell+ x@ execute false
68 ELSE dup last-forget a! true
75 : FORGET ( <name> -- , execute latest [FORGET] )
78 ELSE ." FORGET - couldn't find " count type cr abort
82 : ANEW ( -- , forget if defined then redefine )
90 : MARKER ( <name> -- , define a word that forgets itself when executed, ANS )
92 latest namebase - \ convert to relocatable
95 @ namebase + \ convert back to NFA