File:  [gforth] / gforth / chains.fs
Revision 1.7: download - view: text, annotated - select for diffs
Mon Dec 31 18:40:23 2007 UTC (16 years, 3 months ago) by anton
Branches: MAIN
CVS tags: HEAD
updated copyright notices for GPL v3

    1: \ chains.fs execution chains for gforth			21jun97jaw
    2: 
    3: \ Copyright (C) 1998,2000,2003 Free Software Foundation, Inc.
    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
    9: \ as published by the Free Software Foundation, either version 3
   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, see http://www.gnu.org/licenses/.
   19: 
   20: 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: has? cross 
   37: [IF]   e? compiler
   38: [ELSE] true
   39: [THEN]
   40: 
   41: [IF] \ only needed with compiler
   42: 
   43: [IFUNDEF] linked
   44: : linked        here over @ a, swap ! ;
   45: [THEN]
   46: 
   47: \ generic chains
   48: 
   49: : chained 	( xt list -- ) \ gforth
   50:   linked , ;
   51: 
   52: [THEN]
   53: 
   54: : chainperform	( list -- ) \ gforth
   55:   BEGIN @ dup WHILE dup cell+ perform REPEAT drop ;
   56: 

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