home *** CD-ROM | disk | FTP | other *** search
- \ Headerless words for F-PC by George T. Hawkins
-
- \ yhere xhere here \ get initial dictionary locations
-
- only
- forth also hidden also definitions
-
- create h-pvoc \ the headerless pseudo vocabulary
- #threads 2* allot \ thread area
-
- \ Initializes and inserts the headerless pseudo vocabulary
- \ into the search order.
- : hv-insert ( -- )
- h-pvoc [ #threads 2* literal ] erase
- context @ \ save context on stack
- h-pvoc context !
- also \ insert headerless pseudo voc
- context ! ; \ restore current context
-
- 0 value sv-context \ saved context
- 0 value sv-current \ saved current
-
- : cc-save ( -- ) \ saves context & current
- context @ !> sv-context
- current @ !> sv-current ;
-
- : cc-rest ( -- ) \ restores context & current
- sv-context context !
- sv-current current ! ;
-
-
- 0 value ydp-reg \ the "regular" ydp
-
- 0 value ydp-hw \ the "headerless" ydp
-
- \ The following constant/variable keeps track of the "state"
- \ of the headerless word definitions. It has the following
- \ values and interpretations:
- \
- \ h-state value: meaning:
- \
- \ 0 in start or behead state
- \ 1 in initial headerless state
- \ 2 in headers state
- \ 3 in subsequent headerless state
- \
- 0 value h-state
-
- : ydp-shift ( -- ) \ sets offset for headerless words
- #headsegs 16 * yhere - u2/
- 5000
- 2dup u> IF swap THEN drop \ pick smaller of the two
- yhere + !> ydp-hw ;
-
- forth definitions
-
- defer headerless
- defer headers
- defer behead
-
- hidden definitions
-
- : _headerless ( -- ) \ initiates headerless words
- h-state 1 and IF
- cr ." *** Currently in headerless state ***"
- ELSE
- yhere !> ydp-reg \ save regular ydp
- cc-save \ save context & current
- h-state IF \ return to headerless state
- 3 !> h-state \ set state
- ELSE \ initial headerless state
- hv-insert \ insert headerless pvoc
- ydp-shift \ shift ydp
- 1 !> h-state \ set state
- THEN
- also \ put context in search order
- h-pvoc current ! \ defs to pseudo voc
- h-pvoc context ! \ also as context
- ydp-hw ydp ! \ set/restore headerless ydp
- THEN ;
-
- : _headers ( -- ) \ restores regular words
- h-state 1 and IF
- yhere !> ydp-hw \ save headerless ydp
- ydp-reg ydp ! \ restore regular ydp
- 2 !> h-state \ set state
- previous \ remove context from search order
- cc-rest \ restore context & current
- ELSE
- cr ." *** Must use headerless first ***"
- THEN ;
-
- : _behead ( -- ) \ beheads headerless words
- h-state 1 and IF
- cr ." *** Must use headers first ***"
- ELSE
- h-state IF
- 0 !> h-state \ set state
- cc-save \ save context & current
- previous \ remove headerless pvoc
- cc-rest \ restore context & current
- ELSE
- cr ." *** Nothing to behead ***"
- THEN
- THEN ;
-
- forth definitions
-
- 0 value beheadable \ allow the meta compiler to know that we are either
- \ beheading or we are NOT beheading.
- \ Tom Zimmer 12/06/88 15:26:12.57
-
- : hwords+ ( -- ) \ enables headerless words capability
- ['] _headerless is headerless
- ['] _headers is headers
- ['] _behead is behead
- 0 !> h-state
- on> beheadable ;
-
- hwords+
-
- : hwords- ( -- ) \ disables headerless words capability
- ['] noop is headerless
- ['] noop is headers
- ['] noop is behead
- off> beheadable ;
-
-
- only forth also definitions
-
-
- \ display dictionary space used:
-
- \s
-
- cr
- .( BEHEAD.SEQ uses:)
- cr
- here - negate cr .
- .( bytes of code space)
- xhere rot - >r - negate 16 * r> + cr .
- .( bytes of list space)
- yhere - negate cr .
- .( bytes of head space)
- cr
-
-
-