--- gforth/search.fs 2007/07/06 12:54:56 1.29 +++ gforth/search.fs 2007/12/31 18:40:24 1.32 @@ -1,12 +1,12 @@ \ search order wordset 14may93py -\ Copyright (C) 1995,1996,1997,1998,2000,2003,2005 Free Software Foundation, Inc. +\ Copyright (C) 1995,1996,1997,1998,2000,2003,2005,2007 Free Software Foundation, Inc. \ This file is part of Gforth. \ Gforth is free software; you can redistribute it and/or \ modify it under the terms of the GNU General Public License -\ as published by the Free Software Foundation; either version 2 +\ as published by the Free Software Foundation, either version 3 \ of the License, or (at your option) any later version. \ This program is distributed in the hope that it will be useful, @@ -15,14 +15,15 @@ \ GNU General Public License for more details. \ You should have received a copy of the GNU General Public License -\ along with this program; if not, write to the Free Software -\ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. +\ along with this program. If not, see http://www.gnu.org/licenses/. require struct.fs $10 Value maxvp \ current size of search order stack $400 Value maxvp-limit \ upper limit for resizing search order stack 0 AValue vp \ will be initialized later (dynamic) +\ the first cell at vp contains the search order depth, the others +\ contain the wordlists, starting with the last-searched one. : get-current ( -- wid ) \ search \G @i{wid} is the identifier of the current compilation word list. @@ -96,13 +97,10 @@ Variable slowvoc 0 slowvoc ! : (vocfind) ( addr count wid -- nfa|false ) \ !! generalize this to be independent of vp - drop vp dup @ 1- cells over + - DO 2dup I 2@ over <> - IF (search-wordlist) dup - IF nip nip UNLOOP EXIT - THEN drop - ELSE drop 2drop THEN - [ -1 cells ] Literal +LOOP + drop 0 vp @ -DO ( addr count ) \ note that the loop does not reach 0 + 2dup vp i cells + @ (search-wordlist) dup if ( addr count nt ) + nip nip unloop exit then + drop 1 -loop 2drop false ; 0 value locals-wordlist @@ -203,7 +201,9 @@ lookup ! \ our dictionary search order b THEN dup check-maxvp dup vp! - ?dup IF 1- FOR vp cell+ I cells + ! NEXT THEN ; + 0 swap -DO ( wid1 ... widi ) + vp i cells + ! \ note that the loop does not reach 0 + 1 -loop ; : seal ( -- ) \ gforth \G Remove all word lists from the search order stack other than the word