Hash :
1a08f436
Author :
Date :
2010-08-25T09:23:17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
\ @(#)headless.fth 2.10 02/05/02
\ Copyright 1985-1990 Bradley Forthware
\ Copyright 1990-2002 Sun Microsystems, Inc. All Rights Reserved
\ Copyright Use is subject to license terms.
\ Creates headerless dictionary entries, by putting the headers as
\ aliases in the transient space.
\
\ XXX For SPARC only!! 68000 kernel has flag byte in a different
\ place!!!
\ Created structure:
\ Transient - link token (2 or 4 bytes, aligned)
\ name field
\ flag byte (=20 for alias, or 60 if immediate)
\ padding bytes (0,1,2 or 3), value 0
\ pointer token (points to acf in resident space)
\
\ Resident - acf (2 or 4 bytes, aligned)
\ apf ...
\
\ Use as follows (within a given source file):
\ headerless
\ (these words are now headerless)
\ : blah ... ;
\ headerless0
\ (these words are now headerless, too. Used for extra Sun Forth words.)
\ (This can be changed to mean *include* headers, if desired)
\ : blah ... ;
\ headers
\ (these words are now with heads)
\ : blah ... ;
\
\ Use as follows (file-level control):
\ fload extensions/transien.fth
\ transient fload extensions/dispose.fth resident (file will be discarded)
\ fload extensions/alias.fth ( if needed )
\ transient fload extensions/headless.fth resident (file will be discarded)
\ fload blah.fth ... (desired heads will be discarded later)
\ transient fload blah2.fth resident (entire file will be discarded later)
\ true is suppress-headerless?
\ fload blahblah.fth ... (all heads are preserved)
\ false is suppress-headerless?
\ fload blah.fth ... (desired heads will be discarded later)
\ ...
\ dispose (all transient heads and files are discarded)
\ (or .dispose to print statistics messages as well)
\
\ If it is desired to perform more than one dispose cycle, then dispose.fth and
\ headless.fth should be fload'ed normally, *not* into transient!
\ needs transient transien.fth
decimal
\ New version of ($header), puts name in transient
: ($headerless) ( adr len -- )
acf-align
transient ($header) acf-align there token, resident
flagalias
acf-align \ To set lastacf again
;
false value headerless?
: make-headerless ( -- ) ['] ($headerless) is $header ;
: make-headerfull ( -- ) ['] ($header) is $header ;
false value suppress-headerless?
: headerless ( -- )
transient? 0= suppress-headerless? 0= and
if make-headerless 1 is headerless? then
;
: headers ( -- )
transient? 0= if make-headerfull false is headerless? then
;
alias external headers
: -headers ( -- )
headerless? if headerless? 1+ is headerless? else headerless then
;
: +headers ( -- )
headerless? 1 <= if headers else headerless? 1- is headerless? then
;
: alias \ new-name old-name ( -- )
headerless? if
parse-word
transient? 0= dup >r if transient then ($header)
hide $defined $?missing reveal ( old-acf n )
\ We have to create a code field, because setalias is expecting
\ there to be one (which it may subsequently remove!)
colon-cf setalias
r> if resident then
else
alias
then
;
: transient ( -- )
headerless? if make-headerfull then transient
;
: resident ( -- )
headerless? if make-headerless then resident
;
\ How to handle (marginal utility) headerless0 words
: headerless0 ( -- ) headerless ;