Cleanup vocabularys + see-all test.
This commit is contained in:
@ -145,19 +145,7 @@ unit_tests_win64: $(WINDOWS)/uEf64.exe common/all_tests.fs
|
|||||||
wine $^
|
wine $^
|
||||||
|
|
||||||
see_all_test: $(POSIX)/ueforth
|
see_all_test: $(POSIX)/ueforth
|
||||||
echo \
|
echo internals see-all bye | $< >/dev/null
|
||||||
also internals \
|
|
||||||
also posix \
|
|
||||||
also tasks \
|
|
||||||
also streams \
|
|
||||||
also ansi \
|
|
||||||
also termios \
|
|
||||||
also sockets \
|
|
||||||
also telnetd \
|
|
||||||
also httpd \
|
|
||||||
also web-interface \
|
|
||||||
also editor \
|
|
||||||
see-all bye | $< >/dev/null
|
|
||||||
|
|
||||||
# ---- GENERATED ----
|
# ---- GENERATED ----
|
||||||
|
|
||||||
|
|||||||
@ -21,6 +21,8 @@
|
|||||||
#define CELL_ALIGNED(a) (((cell_t) (a) + CELL_MASK) & ~CELL_MASK)
|
#define CELL_ALIGNED(a) (((cell_t) (a) + CELL_MASK) & ~CELL_MASK)
|
||||||
#define IMMEDIATE 1
|
#define IMMEDIATE 1
|
||||||
#define SMUDGE 2
|
#define SMUDGE 2
|
||||||
|
|
||||||
|
// Maximum ALSO layers.
|
||||||
#define VOCABULARY_DEPTH 16
|
#define VOCABULARY_DEPTH 16
|
||||||
|
|
||||||
#if PRINT_ERRORS
|
#if PRINT_ERRORS
|
||||||
@ -210,13 +212,13 @@ static void forth_init(int argc, char *argv[], void *heap,
|
|||||||
cell_t *rp = g_sys.heap + 1; g_sys.heap += STACK_CELLS;
|
cell_t *rp = g_sys.heap + 1; g_sys.heap += STACK_CELLS;
|
||||||
cell_t *sp = g_sys.heap + 1; g_sys.heap += STACK_CELLS;
|
cell_t *sp = g_sys.heap + 1; g_sys.heap += STACK_CELLS;
|
||||||
|
|
||||||
// FORTH vocabulary
|
// FORTH worldlist (relocated when vocabularies added).
|
||||||
*g_sys.heap++ = 0; cell_t *forth = g_sys.heap;
|
cell_t *forth_wordlist = g_sys.heap;
|
||||||
*g_sys.heap++ = 0; *g_sys.heap++ = 0; *g_sys.heap++ = 0;
|
*g_sys.heap++ = 0;
|
||||||
// Vocabulary stack
|
// Vocabulary stack
|
||||||
g_sys.current = (cell_t **) forth;
|
g_sys.current = (cell_t **) forth_wordlist;
|
||||||
g_sys.context = (cell_t ***) g_sys.heap;
|
g_sys.context = (cell_t ***) g_sys.heap;
|
||||||
*g_sys.heap++ = (cell_t) forth;
|
*g_sys.heap++ = (cell_t) forth_wordlist;
|
||||||
for (int i = 0; i < VOCABULARY_DEPTH; ++i) { *g_sys.heap++ = 0; }
|
for (int i = 0; i < VOCABULARY_DEPTH; ++i) { *g_sys.heap++ = 0; }
|
||||||
|
|
||||||
forth_run(0);
|
forth_run(0);
|
||||||
|
|||||||
@ -29,7 +29,7 @@ internals definitions
|
|||||||
|
|
||||||
: save-name
|
: save-name
|
||||||
'heap @ park-heap !
|
'heap @ park-heap !
|
||||||
forth-wordlist @ park-forth !
|
' forth >body @ park-forth !
|
||||||
w/o create-file throw >r
|
w/o create-file throw >r
|
||||||
saving-base here over - r@ write-file throw
|
saving-base here over - r@ write-file throw
|
||||||
r> close-file throw ;
|
r> close-file throw ;
|
||||||
@ -39,7 +39,7 @@ internals definitions
|
|||||||
saving-base r@ file-size throw r@ read-file throw drop
|
saving-base r@ file-size throw r@ read-file throw drop
|
||||||
r> close-file throw
|
r> close-file throw
|
||||||
park-heap @ 'heap !
|
park-heap @ 'heap !
|
||||||
park-forth @ forth-wordlist !
|
park-forth @ ' forth >body !
|
||||||
'cold @ dup if execute else drop then ;
|
'cold @ dup if execute else drop then ;
|
||||||
|
|
||||||
defer remember-filename
|
defer remember-filename
|
||||||
|
|||||||
@ -58,6 +58,9 @@ variable confirm-old-type
|
|||||||
: <assert ( actual expected -- )
|
: <assert ( actual expected -- )
|
||||||
2dup >= if }confirm ." MUST BE LESS THAN: " .
|
2dup >= if }confirm ." MUST BE LESS THAN: " .
|
||||||
." ACTUAL: " . space 0 assert then 2drop ;
|
." ACTUAL: " . space 0 assert then 2drop ;
|
||||||
|
: >assert ( actual expected -- )
|
||||||
|
2dup <= if }confirm ." MUST BE GREATER THAN: " .
|
||||||
|
." ACTUAL: " . space 0 assert then 2drop ;
|
||||||
|
|
||||||
( Input testing )
|
( Input testing )
|
||||||
create in-buffer 1000 allot
|
create in-buffer 1000 allot
|
||||||
|
|||||||
@ -56,11 +56,24 @@ internals definitions
|
|||||||
dup @ ['] see-loop @ <>
|
dup @ ['] see-loop @ <>
|
||||||
if ." Unsupported word type: " see. cr exit then
|
if ." Unsupported word type: " see. cr exit then
|
||||||
['] : see. dup see. space see-loop ['] ; see. cr ;
|
['] : see. dup see. space see-loop ['] ; see. cr ;
|
||||||
: see-all 0 context @ @ begin dup while dup see-xt >link repeat 2drop cr ;
|
: >name-length ( xt -- n ) dup 0= if exit then >name nip ;
|
||||||
: voc. ( voc -- ) dup forth-wordlist = if ." FORTH " drop exit then 3 cells - see. ;
|
: see-vocabulary ( voc ) @ begin dup >name-length while dup see-xt >link repeat drop cr ;
|
||||||
|
: >vocnext ( xt -- xt ) >body 2 cells + @ ;
|
||||||
|
: see-all
|
||||||
|
last-vocabulary @ begin dup while
|
||||||
|
." VOCABULARY " dup see. cr ." ------------------------" cr
|
||||||
|
dup >body see-vocabulary
|
||||||
|
>vocnext
|
||||||
|
repeat drop cr ;
|
||||||
|
: voclist last-vocabulary @ begin dup while dup see. >vocnext repeat drop cr ;
|
||||||
|
: voc. ( voc -- ) 2 cells - see. ;
|
||||||
|
: vocs. ( voc -- ) dup voc. @ begin dup while
|
||||||
|
dup >name-length 0= if ." >> " dup 2 cells - voc. then
|
||||||
|
>link
|
||||||
|
repeat drop cr ;
|
||||||
forth definitions also internals
|
forth definitions also internals
|
||||||
: see ' see-xt ;
|
: see ' see-xt ;
|
||||||
: order context begin dup @ while dup @ voc. cell+ repeat drop cr ;
|
: order context begin dup @ while dup @ vocs. cell+ repeat drop ;
|
||||||
only forth definitions
|
only forth definitions
|
||||||
|
|
||||||
( List words in Dictionary / Vocabulary )
|
( List words in Dictionary / Vocabulary )
|
||||||
@ -68,7 +81,6 @@ internals definitions
|
|||||||
75 value line-width
|
75 value line-width
|
||||||
: onlines ( n xt -- n xt )
|
: onlines ( n xt -- n xt )
|
||||||
swap dup line-width > if drop 0 cr then over >name nip + 1+ swap ;
|
swap dup line-width > if drop 0 cr then over >name nip + 1+ swap ;
|
||||||
: >name-length ( xt -- n ) dup 0= if exit then >name nip ;
|
|
||||||
forth definitions also internals
|
forth definitions also internals
|
||||||
: vlist 0 context @ @ begin dup >name-length while onlines dup see. >link repeat 2drop cr ;
|
: vlist 0 context @ @ begin dup >name-length while onlines dup see. >link repeat 2drop cr ;
|
||||||
: words 0 context @ @ begin dup while onlines dup see. >link repeat 2drop cr ;
|
: words 0 context @ @ begin dup while onlines dup see. >link repeat 2drop cr ;
|
||||||
|
|||||||
@ -13,12 +13,17 @@
|
|||||||
\ limitations under the License.
|
\ limitations under the License.
|
||||||
|
|
||||||
( Implement Vocabularies )
|
( Implement Vocabularies )
|
||||||
|
( normal: link, flags&len, code )
|
||||||
|
( vocab: link, flags&len, code | link , len=0, voclink )
|
||||||
variable last-vocabulary
|
variable last-vocabulary
|
||||||
current @ constant forth-wordlist
|
: vocabulary ( "name" )
|
||||||
: forth forth-wordlist context ! ;
|
create current @ 2 cells + , 0 , last-vocabulary @ ,
|
||||||
: vocabulary ( "name" ) create 0 , current @ 2 cells + , current @ @ last-vocabulary !
|
current @ @ last-vocabulary !
|
||||||
does> cell+ context ! ;
|
does> context ! ;
|
||||||
: definitions context @ current ! ;
|
: definitions context @ current ! ;
|
||||||
|
vocabulary FORTH
|
||||||
|
' forth >body @ >link ' forth >body !
|
||||||
|
forth definitions
|
||||||
|
|
||||||
( Make it easy to transfer words between vocabularies )
|
( Make it easy to transfer words between vocabularies )
|
||||||
: xt-find& ( xt -- xt& ) context @ begin 2dup @ <> while @ >link& repeat nip ;
|
: xt-find& ( xt -- xt& ) context @ begin 2dup @ <> while @ >link& repeat nip ;
|
||||||
@ -32,7 +37,7 @@ current @ constant forth-wordlist
|
|||||||
: only forth 0 context cell+ ! ;
|
: only forth 0 context cell+ ! ;
|
||||||
: voc-stack-end ( -- a ) context begin dup @ while cell+ repeat ;
|
: voc-stack-end ( -- a ) context begin dup @ while cell+ repeat ;
|
||||||
: also context context cell+ voc-stack-end over - 2 cells + cmove> ;
|
: also context context cell+ voc-stack-end over - 2 cells + cmove> ;
|
||||||
: sealed 0 last-vocabulary @ >body cell+ ! ;
|
: sealed 0 last-vocabulary @ >body ! ;
|
||||||
|
|
||||||
( Hide some words in an internals vocabulary )
|
( Hide some words in an internals vocabulary )
|
||||||
vocabulary internals internals definitions
|
vocabulary internals internals definitions
|
||||||
@ -42,8 +47,7 @@ variable scope scope context cell - !
|
|||||||
|
|
||||||
transfer{
|
transfer{
|
||||||
xt-find& xt-hide xt-transfer
|
xt-find& xt-hide xt-transfer
|
||||||
voc-stack-end forth-wordlist
|
voc-stack-end last-vocabulary
|
||||||
last-vocabulary
|
|
||||||
branch 0branch donext dolit
|
branch 0branch donext dolit
|
||||||
'context 'notfound notfound
|
'context 'notfound notfound
|
||||||
immediate? input-buffer ?echo ?arrow. arrow
|
immediate? input-buffer ?echo ?arrow. arrow
|
||||||
|
|||||||
@ -50,7 +50,10 @@ e: test-order
|
|||||||
vocabulary baz
|
vocabulary baz
|
||||||
also foo also bar also baz
|
also foo also bar also baz
|
||||||
order
|
order
|
||||||
out: baz bar foo FORTH
|
out: baz >> FORTH
|
||||||
|
out: bar >> FORTH
|
||||||
|
out: foo >> FORTH
|
||||||
|
out: FORTH
|
||||||
only forth definitions
|
only forth definitions
|
||||||
;e
|
;e
|
||||||
|
|
||||||
@ -102,6 +105,20 @@ e: test-sealed
|
|||||||
only forth definitions
|
only forth definitions
|
||||||
;e
|
;e
|
||||||
|
|
||||||
|
e: test-nested
|
||||||
|
vocabulary foo
|
||||||
|
foo definitions
|
||||||
|
: hi ;
|
||||||
|
: there ;
|
||||||
|
vocabulary bar
|
||||||
|
bar definitions
|
||||||
|
: a ;
|
||||||
|
: b ;
|
||||||
|
vlist
|
||||||
|
out: b a
|
||||||
|
only forth definitions
|
||||||
|
;e
|
||||||
|
|
||||||
e: test-fixed-does>-normal
|
e: test-fixed-does>-normal
|
||||||
: adder create , does> @ + ;
|
: adder create , does> @ + ;
|
||||||
3 adder foo
|
3 adder foo
|
||||||
@ -109,6 +126,17 @@ e: test-fixed-does>-normal
|
|||||||
4 ' foo execute 7 =assert
|
4 ' foo execute 7 =assert
|
||||||
;e
|
;e
|
||||||
|
|
||||||
|
also internals
|
||||||
|
variable see-tally
|
||||||
|
: tally-type ( a n -- ) nip see-tally +! ;
|
||||||
|
: test-see-all
|
||||||
|
0 see-tally !
|
||||||
|
['] tally-type is type
|
||||||
|
see-all
|
||||||
|
['] default-type is type
|
||||||
|
see-tally @ 36000 >assert
|
||||||
|
;
|
||||||
|
|
||||||
(
|
(
|
||||||
e: test-fixed-does>-interp
|
e: test-fixed-does>-interp
|
||||||
create hi 123 , does> @ + ;
|
create hi 123 , does> @ + ;
|
||||||
|
|||||||
@ -111,14 +111,21 @@ stdout console-mode GetConsoleMode drop
|
|||||||
stdout console-mode @ ENABLE_VIRTUAL_TERMINAL_PROCESSING or SetConsoleMode drop
|
stdout console-mode @ ENABLE_VIRTUAL_TERMINAL_PROCESSING or SetConsoleMode drop
|
||||||
|
|
||||||
: win-type ( a n -- ) stdout -rot NULL NULL WriteFile drop ;
|
: win-type ( a n -- ) stdout -rot NULL NULL WriteFile drop ;
|
||||||
' win-type is type
|
|
||||||
: raw-key ( -- n ) 0 >r stdin rp@ 1 NULL NULL ReadFile drop r> ;
|
: raw-key ( -- n ) 0 >r stdin rp@ 1 NULL NULL ReadFile drop r> ;
|
||||||
: win-key? ( -- f ) stdin 0 WaitForSingleObject 0= ;
|
: win-key? ( -- f ) stdin 0 WaitForSingleObject 0= ;
|
||||||
' win-key? is key?
|
|
||||||
: win-key ( -- n ) raw-key dup 13 = if drop nl then ;
|
: win-key ( -- n ) raw-key dup 13 = if drop nl then ;
|
||||||
' win-key is key
|
|
||||||
: win-bye ( -- ) 0 ExitProcess drop ;
|
: win-bye ( -- ) 0 ExitProcess drop ;
|
||||||
|
|
||||||
|
also forth definitions
|
||||||
|
: default-type win-type ;
|
||||||
|
: default-key win-key ;
|
||||||
|
: default-key? win-key? ;
|
||||||
|
only windows definitions
|
||||||
|
' default-type is type
|
||||||
|
' default-key is key
|
||||||
|
' default-key? is key?
|
||||||
' win-bye is bye
|
' win-bye is bye
|
||||||
|
|
||||||
-1 echo !
|
-1 echo !
|
||||||
|
|
||||||
ansi
|
ansi
|
||||||
|
|||||||
Reference in New Issue
Block a user