[gforth] / gforth / wordlib.fs  

gforth: gforth/wordlib.fs


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

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help