Annotation of gforth/wordlib.fs, revision 1.8

1.1       jwilke      1: \ wordlib.fs Handle shared library with forth primitive extentions 9oct97jaw
                      2: 
1.8     ! anton       3: \ Copyright (C) 1995,1996,1997,1998,1999,2000,2003,2007 Free Software Foundation, Inc.
1.1       jwilke      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
1.7       anton       9: \ as published by the Free Software Foundation, either version 3
1.1       jwilke     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
1.7       anton      18: \ along with this program. If not, see http://www.gnu.org/licenses/.
1.1       jwilke     19: 
                     20: \ Author: Jens Wilke
                     21: \ Revision Log
                     22: \ 09oct97jaw V1.0   Initial Version
                     23: 
                     24: \ ToDo:
                     25: \
                     26: \ Bootup initialization
                     27: \ "require" for libs
                     28: 
                     29: 0 Value wlib   \ temporary library handle to make live easy
                     30: 
1.2       jwilke     31: : wl-catalog ( n lib-addr -- addr | u )
                     32:     s" catalog" rot lib-sym dup 0=
1.1       jwilke     33:     ABORT" No word catalog"
                     34:     icall1 ;
                     35: 
                     36: : wl-words ( lib-addr -- )
1.2       jwilke     37:     0 
                     38:     BEGIN 2dup swap wl-catalog ?dup
1.1       jwilke     39:     WHILE cell+ count type space
                     40:          1+
1.2       jwilke     41:     REPEAT 2drop ;
1.1       jwilke     42: 
                     43: : wl-create ( adr adr2 len2 -- )
                     44:     nextname
                     45:     Create ,
1.2       jwilke     46:     DOES> @ wcall ;
1.1       jwilke     47: 
1.2       jwilke     48: : wl-tovoc ( lib-addr -- )
1.1       jwilke     49:     0 
1.2       jwilke     50:     BEGIN 2dup swap wl-catalog ?dup
1.1       jwilke     51:     WHILE dup @ swap cell+ count wl-create
                     52:          1+
1.2       jwilke     53:     REPEAT 2drop ;
1.1       jwilke     54: 
                     55: : (WordLibrary)
                     56:     Create DOES> @ ;
                     57: 
                     58: : WordLibrary ( "wordname" "libfilename" )
                     59:     (WordLibrary)
                     60:     \ open library with forth path
                     61:     bl word count open-fpath-file throw rot close-file throw
                     62:     \ open library with correct path
                     63:     open-lib
1.2       jwilke     64:     dup 0= ABORT" Library load error"
                     65:     dup ,
1.1       jwilke     66:     wl-tovoc ;

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