--- gforth/glocals.fs 2003/03/09 15:16:49 1.52 +++ gforth/glocals.fs 2004/12/31 13:23:57 1.55 @@ -1,6 +1,6 @@ \ A powerful locals implementation -\ Copyright (C) 1995,1996,1997,1998,2000,2003 Free Software Foundation, Inc. +\ Copyright (C) 1995,1996,1997,1998,2000,2003,2004 Free Software Foundation, Inc. \ This file is part of Gforth. @@ -310,15 +310,21 @@ immediate immediate forth definitions +also locals-types + +\ these "locals" are used for comparison in TO +c: some-clocal 2drop +d: some-dlocal 2drop +f: some-flocal 2drop +w: some-wlocal 2drop + \ the following gymnastics are for declaring locals without type specifier. \ we exploit a feature of our dictionary: every wordlist \ has it's own methods for finding words etc. \ So we create a vocabulary new-locals, that creates a 'w:' local named x \ when it is asked if it contains x. -also locals-types - : new-locals-find ( caddr u w -- nfa ) \ this is the find method of the new-locals vocabulary \ make a new local with name caddr u; w is ignored @@ -349,10 +355,10 @@ new-locals-map mappedwordlist Constant n variable old-dpp \ and now, finally, the user interface words -: { ( -- lastxt wid 0 ) \ gforth open-brace +: { ( -- latestxt wid 0 ) \ gforth open-brace dp old-dpp ! locals-dp dpp ! - lastxt get-current + latestxt get-current get-order new-locals-wl swap 1+ set-order also locals definitions locals-types 0 TO locals-wordlist @@ -360,7 +366,7 @@ variable old-dpp locals-types definitions -: } ( lastxt wid 0 a-addr1 xt1 ... -- ) \ gforth close-brace +: } ( latestxt wid 0 a-addr1 xt1 ... -- ) \ gforth close-brace \ ends locals definitions ] old-dpp @ dpp ! begin @@ -489,7 +495,7 @@ forth definitions : locals-:-hook ( sys -- sys addr xt n ) \ addr is the nfa of the defined word, xt its xt DEFERS :-hook - last @ lastcfa @ + latest latestxt clear-leave-stack 0 locals-size ! locals-buffer locals-dp ! @@ -661,7 +667,6 @@ forth definitions -&32 throw endif ; :noname - 0 0 0. 0.0e0 { c: clocal w: wlocal d: dlocal f: flocal } comp' drop dup >definer case [ ' locals-wordlist ] literal >definer \ value @@ -669,13 +674,13 @@ forth definitions \ !! dependent on c: etc. being does>-defining words \ this works, because >definer uses >does-code in this case, \ which produces a relocatable address - [ comp' clocal drop >definer ] literal + [ comp' some-clocal drop ] literal >definer OF POSTPONE laddr# >body @ lp-offset, POSTPONE c! ENDOF - [ comp' wlocal drop >definer ] literal + [ comp' some-wlocal drop ] literal >definer OF POSTPONE laddr# >body @ lp-offset, POSTPONE ! ENDOF - [ comp' dlocal drop >definer ] literal + [ comp' some-dlocal drop ] literal >definer OF POSTPONE laddr# >body @ lp-offset, POSTPONE 2! ENDOF - [ comp' flocal drop >definer ] literal + [ comp' some-flocal drop ] literal >definer OF POSTPONE laddr# >body @ lp-offset, POSTPONE f! ENDOF -&32 throw endcase ;