[gforth] / gforth / chains.fs  

gforth: gforth/chains.fs


1 : jwilke 1.1 \ chains.fs execution chains for gforth 21jun97jaw
2 :    
3 : anton 1.6 \ Copyright (C) 1998,2000,2003 Free Software Foundation, Inc.
4 : anton 1.3
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 : anton 1.7 \ as published by the Free Software Foundation, either version 3
10 : anton 1.3 \ 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 : anton 1.7 \ along with this program. If not, see http://www.gnu.org/licenses/.
19 : anton 1.3
20 : jwilke 1.1 0 [IF]
21 :     This defines execution chains.
22 :     The first application for this is building initialization chains:
23 :     Think of many modules or program parts, each of it with some specific
24 :     initialization code. If we hardcode the initialization routines into a
25 :     "master-init" we will get unflexible and are not able only to load some
26 :     specific modules...
27 :    
28 :     The chain is basicaly a linked-list. Define a Variable for the head of
29 :     linked-list. Name it "foo8" or "foo-chain" to indicate it is a execution
30 :     chain.
31 :    
32 :     You can add a word to the list with "' my-init foo8 chained". You can
33 :     execute all the code with "foo8 chainperform".
34 :     [THEN]
35 :    
36 : pazsan 1.2 has? cross
37 :     [IF] e? compiler
38 :     [ELSE] true
39 :     [THEN]
40 :    
41 :     [IF] \ only needed with compiler
42 :    
43 : jwilke 1.1 [IFUNDEF] linked
44 :     : linked here over @ a, swap ! ;
45 :     [THEN]
46 :    
47 :     \ generic chains
48 :    
49 :     : chained ( xt list -- ) \ gforth
50 :     linked , ;
51 : pazsan 1.2
52 :     [THEN]
53 : jwilke 1.1
54 :     : chainperform ( list -- ) \ gforth
55 :     BEGIN @ dup WHILE dup cell+ perform REPEAT drop ;
56 :    

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help