Fixing up vocabularies and previous.
This commit is contained in:
@ -361,6 +361,7 @@ e: check-blocks
|
||||
e: check-vocabulary
|
||||
out: internals
|
||||
out: sealed
|
||||
out: previous
|
||||
out: also
|
||||
out: only
|
||||
out: transfer{
|
||||
|
||||
@ -39,6 +39,9 @@ forth definitions
|
||||
: only forth 0 context cell+ ! ;
|
||||
: voc-stack-end ( -- a ) context begin dup @ while cell+ repeat ;
|
||||
: also context context cell+ voc-stack-end over - 2 cells + cmove> ;
|
||||
: previous
|
||||
voc-stack-end context cell+ = throw
|
||||
context cell+ context voc-stack-end over - cell+ cmove ;
|
||||
: sealed 0 last-vocabulary @ >body ! ;
|
||||
|
||||
( Hide some words in an internals vocabulary )
|
||||
|
||||
@ -57,6 +57,32 @@ e: test-order
|
||||
only forth definitions
|
||||
;e
|
||||
|
||||
e: test-order-previous
|
||||
vocabulary foo
|
||||
vocabulary bar
|
||||
vocabulary baz
|
||||
also foo also bar also baz
|
||||
order
|
||||
out: baz >> FORTH
|
||||
out: bar >> FORTH
|
||||
out: foo >> FORTH
|
||||
out: FORTH
|
||||
previous order
|
||||
out: bar >> FORTH
|
||||
out: foo >> FORTH
|
||||
out: FORTH
|
||||
previous order
|
||||
out: foo >> FORTH
|
||||
out: FORTH
|
||||
previous order
|
||||
out: FORTH
|
||||
;e
|
||||
|
||||
e: test-previous-throw
|
||||
only forth definitions
|
||||
' previous catch 0<> assert
|
||||
;e
|
||||
|
||||
e: test-vocab-define-order
|
||||
vocabulary foo
|
||||
foo definitions
|
||||
|
||||
@ -39,4 +39,4 @@ z" setsockopt" 5 sysfunc setsockopt
|
||||
( Fixup return )
|
||||
: sockaccept sockaccept sign-extend ;
|
||||
|
||||
forth definitions
|
||||
only forth definitions
|
||||
|
||||
@ -68,6 +68,7 @@ TRANSFER ( "name" ) Move a word from its current dictionary to the current vocab
|
||||
Useful for "hiding" built-in words
|
||||
TRANSFER{ ..words.. }TRANSFER ( -- ) Transfer multiple words to the current vocabulary
|
||||
ALSO ( -- ) Duplicate the vocabulary at the top of the vocabulary stack
|
||||
PREVIOUS ( -- ) Drop the vocabulary at the top of the vocabulary stack
|
||||
ONLY ( -- ) Reset context stack to one item, the FORTH dictionary
|
||||
Non-standard, as there's no distinct ONLY vocabulary
|
||||
ORDER ( -- ) Print the vocabulary search order
|
||||
|
||||
Reference in New Issue
Block a user