Builtins now vlisting.
This commit is contained in:
@ -59,6 +59,7 @@ static struct {
|
||||
// Layout not used by Forth.
|
||||
cell_t *rp; // spot to park main thread
|
||||
cell_t DOLIT_XT, DOFLIT_XT, DOEXIT_XT, YIELD_XT;
|
||||
void *DOCREATE_OP;
|
||||
const BUILTIN_WORD *builtins;
|
||||
} g_sys;
|
||||
|
||||
@ -260,7 +261,7 @@ static void forth_init(int argc, char *argv[], void *heap,
|
||||
forth_run(0);
|
||||
#define V(name) \
|
||||
create(#name "-builtins", sizeof(#name "-builtins") - 1, \
|
||||
BUILTIN_FORK, 0); \
|
||||
BUILTIN_FORK, g_sys.DOCREATE_OP); \
|
||||
*g_sys.heap++ = VOC_ ## name;
|
||||
VOCABULARY_LIST
|
||||
#undef V
|
||||
|
||||
@ -31,6 +31,7 @@ static cell_t *forth_run(cell_t *init_rp) {
|
||||
};
|
||||
|
||||
if (!init_rp) {
|
||||
g_sys.DOCREATE_OP = ADDR_DOCREATE;
|
||||
g_sys.builtins = builtins;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -125,4 +125,5 @@ typedef struct {
|
||||
sp = evaluate1(sp, &tfp); \
|
||||
fp = tfp; w = *sp--; DROP; if (w) JMPW) \
|
||||
Y(EXIT, ip = (cell_t *) *rp--) \
|
||||
XV(internals, "'builtins", TBUILTINS, DUP; tos = (cell_t) g_sys.builtins) \
|
||||
XV(forth_immediate, ";", SEMICOLON, COMMA(g_sys.DOEXIT_XT); UNSMUDGE(); g_sys.state = 0)
|
||||
|
||||
@ -59,6 +59,7 @@ internals definitions
|
||||
dup @ ['] see-loop @ = if
|
||||
['] : see. dup see. space see-loop ['] ; see. cr exit
|
||||
then
|
||||
dup >flags BUILTIN_FORK and if ." Built-in fork: " see. exit then
|
||||
dup @ ['] input-buffer @ = if ." CREATE/VARIABLE: " see. cr exit then
|
||||
dup @ ['] SMUDGE @ = if ." DOES>/CONSTANT: " see. cr exit then
|
||||
dup >params 0= if ." Built-in: " see. cr exit then
|
||||
@ -102,11 +103,22 @@ only forth definitions
|
||||
( List words in Dictionary / Vocabulary )
|
||||
internals definitions
|
||||
70 value line-width
|
||||
: onlines ( n xt -- n xt )
|
||||
swap dup line-width > if drop 0 cr then over >name nip + 1+ swap ;
|
||||
0 value line-pos
|
||||
: onlines ( xt -- xt )
|
||||
line-pos line-width > if cr 0 to line-pos then
|
||||
dup >name nip 1+ line-pos + to line-pos ;
|
||||
: vins. ( voc -- )
|
||||
>r 'builtins 2 cells + begin dup 2 cells - @ while
|
||||
dup >params r@ = if dup onlines see. then
|
||||
3 cells +
|
||||
repeat drop rdrop ;
|
||||
: ins. ( n xt -- n ) cell+ @ vins. ;
|
||||
: ?ins. ( xt -- xt ) dup >flags BUILTIN_FORK and if dup ins. then ;
|
||||
forth definitions also internals
|
||||
: vlist 0 context @ @ begin dup nonvoc? while onlines dup see. >link repeat 2drop cr ;
|
||||
: words 0 context @ @ begin dup while onlines dup see. >link repeat 2drop cr ;
|
||||
: vlist 0 to line-pos context @ @
|
||||
begin dup nonvoc? while onlines dup ?ins. see. >link repeat drop cr ;
|
||||
: words 0 to line-pos context @ @
|
||||
begin dup while onlines dup see. >link repeat drop cr ;
|
||||
only forth definitions
|
||||
|
||||
( Extra Task Utils )
|
||||
|
||||
@ -41,6 +41,7 @@ static cell_t *forth_run(cell_t *init_rp) {
|
||||
};
|
||||
|
||||
if (!init_rp) {
|
||||
g_sys.DOCREATE_OP = ADDR_DOCREATE;
|
||||
g_sys.builtins = builtins;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user