Annotation of gforth/savesys.fs, revision 1.11

1.1       anton       1: \ image dump                                           15nov94py
                      2: 
1.10      anton       3: \ Copyright (C) 1995,1997,2003,2006,2007 Free Software Foundation, Inc.
1.1       anton       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.11    ! anton       9: \ as published by the Free Software Foundation, either version 3
1.1       anton      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.11    ! anton      18: \ along with this program. If not, see http://www.gnu.org/licenses/.
1.1       anton      19: 
1.7       anton      20: : save-mem-dict { addr1 u -- addr2 u }
1.1       anton      21:     here { addr2 }
                     22:     u allot
                     23:     addr1 addr2 u move
                     24:     addr2 u ;
                     25: 
1.9       anton      26: : delete-prefix ( c-addr1 u1 c-addr2 u2 -- c-addr3 u3 )
                     27:     \ if c-addr2 u2 is a prefix of c-addr1 u1, delete it
                     28:     2over 2over string-prefix? if
                     29:         nip /string
                     30:     else
                     31:         2drop
                     32:     endif ;
                     33: 
1.1       anton      34: : update-image-included-files ( -- )
                     35:     included-files 2@ { addr cnt }
                     36:     image-included-files 2@ { old-addr old-cnt }
                     37:     align here { new-addr }
                     38:     cnt 2* cells allot
                     39:     new-addr cnt image-included-files 2!
                     40:     old-addr new-addr old-cnt 2* cells move
                     41:     cnt old-cnt
                     42:     U+DO
1.9       anton      43:         addr i 2* cells + 2@
                     44:         s" GFORTHDESTDIR" getenv delete-prefix save-mem-dict
1.1       anton      45:        new-addr i 2* cells + 2!
                     46:     LOOP
                     47:     maxalign ;
                     48: 
                     49: : dump-fi ( addr u -- )
                     50:     w/o bin create-file throw >r
                     51:     update-image-included-files
1.5       anton      52:     update-image-order
1.1       anton      53:     here forthstart - forthstart 2 cells + !
                     54:     forthstart
                     55:     begin \ search for start of file ("#! " at a multiple of 8)
                     56:        8 -
1.4       anton      57:        dup 3 s" #! " str=
1.1       anton      58:     until ( imagestart )
                     59:     here over - r@ write-file throw
                     60:     r> close-file throw ;
                     61: 
                     62: : savesystem ( "name" -- ) \ gforth
                     63:     name dump-fi ;

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