Inlined more words.
This commit is contained in:
@ -20,17 +20,14 @@
|
|||||||
: constant ( n "name" -- ) create , does> @ ;
|
: constant ( n "name" -- ) create , does> @ ;
|
||||||
: variable ( "name" -- ) create 0 , ;
|
: variable ( "name" -- ) create 0 , ;
|
||||||
|
|
||||||
( System Variables )
|
( Stack Baseline )
|
||||||
: sys: ( a -- a' "name" ) dup constant cell+ ;
|
sp@ constant sp0
|
||||||
'sys sys: 'heap sys: current sys: 'context
|
rp@ constant rp0
|
||||||
sys: 'latestxt sys: 'notfound
|
fp@ constant fp0
|
||||||
sys: 'heap-start sys: 'heap-size sys: 'stack-cells
|
: depth ( -- n ) sp@ sp0 - cell/ ;
|
||||||
sys: 'boot sys: 'boot-size
|
: fdepth ( -- n ) fp@ fp0 - 4 / ;
|
||||||
sys: 'tib sys: #tib sys: >in
|
|
||||||
sys: state sys: base
|
( Useful heap size words )
|
||||||
sys: 'argc sys: 'argv sys: 'runner
|
|
||||||
: context ( -- a ) 'context @ cell+ ;
|
|
||||||
: latestxt ( -- xt ) 'latestxt @ ;
|
|
||||||
: remaining ( -- n ) 'heap-start @ 'heap-size @ + 'heap @ - ;
|
: remaining ( -- n ) 'heap-start @ 'heap-size @ + 'heap @ - ;
|
||||||
: used ( -- n ) 'heap @ sp@ 'stack-cells @ cells + - 28 + ;
|
: used ( -- n ) 'heap @ sp@ 'stack-cells @ cells + - 28 + ;
|
||||||
|
|
||||||
@ -64,13 +61,6 @@
|
|||||||
: immediate? ( xt -- f ) >flags 1 and 0= 0= ;
|
: immediate? ( xt -- f ) >flags 1 and 0= 0= ;
|
||||||
: postpone ' dup immediate? if , else aliteral ['] , , then ; immediate
|
: postpone ' dup immediate? if , else aliteral ['] , , then ; immediate
|
||||||
|
|
||||||
( Stack Convience )
|
|
||||||
sp@ constant sp0
|
|
||||||
rp@ constant rp0
|
|
||||||
fp@ constant fp0
|
|
||||||
: depth ( -- n ) sp@ sp0 - cell/ ;
|
|
||||||
: fdepth ( -- n ) fp@ fp0 - 4 / ;
|
|
||||||
|
|
||||||
( Rstack nest depth )
|
( Rstack nest depth )
|
||||||
variable nest-depth
|
variable nest-depth
|
||||||
|
|
||||||
|
|||||||
@ -77,6 +77,18 @@
|
|||||||
: >name ( xt -- a n ) dup >name-length swap >link& over aligned - swap ;
|
: >name ( xt -- a n ) dup >name-length swap >link& over aligned - swap ;
|
||||||
: >body ( xt -- a ) dup @ [ ' >flags @ ] literal = 2 + cells + ;
|
: >body ( xt -- a ) dup @ [ ' >flags @ ] literal = 2 + cells + ;
|
||||||
|
|
||||||
|
( System Variables )
|
||||||
|
: sys: ( a -- a' "name" ) dup constant cell+ ;
|
||||||
|
'sys sys: 'heap sys: current sys: 'context
|
||||||
|
sys: 'latestxt sys: 'notfound
|
||||||
|
sys: 'heap-start sys: 'heap-size sys: 'stack-cells
|
||||||
|
sys: 'boot sys: 'boot-size
|
||||||
|
sys: 'tib sys: #tib sys: >in
|
||||||
|
sys: state sys: base
|
||||||
|
sys: 'argc sys: 'argv sys: 'runner
|
||||||
|
: context ( -- a ) 'context @ cell+ ;
|
||||||
|
: latestxt ( -- xt ) 'latestxt @ ;
|
||||||
|
|
||||||
: f= ( r r -- f ) f- f0= ;
|
: f= ( r r -- f ) f- f0= ;
|
||||||
: f< ( r r -- f ) f- f0< ;
|
: f< ( r r -- f ) f- f0< ;
|
||||||
: f> ( r r -- f ) fswap f< ;
|
: f> ( r r -- f ) fswap f< ;
|
||||||
|
|||||||
@ -70,4 +70,24 @@
|
|||||||
X(">link&", TOLINKAT, tos = (cell_t) TOLINK(tos)) \
|
X(">link&", TOLINKAT, tos = (cell_t) TOLINK(tos)) \
|
||||||
X(">link", TOLINK, tos = *TOLINK(tos)) \
|
X(">link", TOLINK, tos = *TOLINK(tos)) \
|
||||||
X(">name", TONAME, DUP; *sp = (cell_t) TONAME(tos); tos = *TONAMELEN(tos)) \
|
X(">name", TONAME, DUP; *sp = (cell_t) TONAME(tos); tos = *TONAMELEN(tos)) \
|
||||||
X(">body", TOBODY, tos = (cell_t) TOBODY(tos))
|
X(">body", TOBODY, tos = (cell_t) TOBODY(tos)) \
|
||||||
|
XV(internals, "'heap", THEAP, DUP; tos = (cell_t) &g_sys.heap) \
|
||||||
|
Y(current, DUP; tos = (cell_t) &g_sys.current) \
|
||||||
|
XV(internals, "'context", TCONTEXT, DUP; tos = (cell_t) &g_sys.context) \
|
||||||
|
XV(internals, "'latestxt", TLATESTXT, DUP; tos = (cell_t) &g_sys.latestxt) \
|
||||||
|
XV(internals, "'notfound", TNOTFOUND, DUP; tos = (cell_t) &g_sys.notfound) \
|
||||||
|
XV(internals, "'heap-start", THEAP_START, DUP; tos = (cell_t) &g_sys.heap_start) \
|
||||||
|
XV(internals, "'heap-size", THEAP_SIZE, DUP; tos = (cell_t) &g_sys.heap_size) \
|
||||||
|
XV(internals, "'stack-cells", TSTACK_CELLS, DUP; tos = (cell_t) &g_sys.stack_cells) \
|
||||||
|
XV(internals, "'boot", TBOOT, DUP; tos = (cell_t) &g_sys.boot) \
|
||||||
|
XV(internals, "'boot-size", TBOOT_SIZE, DUP; tos = (cell_t) &g_sys.boot_size) \
|
||||||
|
XV(internals, "'tib", TTIB, DUP; tos = (cell_t) &g_sys.tib) \
|
||||||
|
X("#tib", NTIB, DUP; tos = (cell_t) &g_sys.ntib) \
|
||||||
|
X(">in", TIN, DUP; tos = (cell_t) &g_sys.tin) \
|
||||||
|
Y(state, DUP; tos = (cell_t) &g_sys.state) \
|
||||||
|
Y(base, DUP; tos = (cell_t) &g_sys.base) \
|
||||||
|
XV(internals, "'argc", ARGC, DUP; tos = (cell_t) &g_sys.argc) \
|
||||||
|
XV(internals, "'argv", ARGV, DUP; tos = (cell_t) &g_sys.argv) \
|
||||||
|
XV(internals, "'runner", RUNNER, DUP; tos = (cell_t) &g_sys.runner) \
|
||||||
|
Y(context, DUP; tos = (cell_t) (g_sys.context + 1)) \
|
||||||
|
Y(latestxt, DUP; tos = (cell_t) g_sys.latestxt)
|
||||||
|
|||||||
@ -108,11 +108,6 @@ e: check-boot
|
|||||||
out: next
|
out: next
|
||||||
out: for
|
out: for
|
||||||
out: nest-depth
|
out: nest-depth
|
||||||
out: fdepth
|
|
||||||
out: depth
|
|
||||||
out: fp0
|
|
||||||
out: rp0
|
|
||||||
out: sp0
|
|
||||||
out: postpone
|
out: postpone
|
||||||
out: recurse
|
out: recurse
|
||||||
out: aft
|
out: aft
|
||||||
@ -134,13 +129,11 @@ e: check-boot
|
|||||||
out: [
|
out: [
|
||||||
out: used
|
out: used
|
||||||
out: remaining
|
out: remaining
|
||||||
out: latestxt
|
out: fdepth
|
||||||
out: context
|
out: depth
|
||||||
out: base
|
out: fp0
|
||||||
out: state
|
out: rp0
|
||||||
out: >in
|
out: sp0
|
||||||
out: #tib
|
|
||||||
out: current
|
|
||||||
out: variable
|
out: variable
|
||||||
out: constant
|
out: constant
|
||||||
out: \
|
out: \
|
||||||
@ -208,6 +201,14 @@ e: check-extra-opcodes
|
|||||||
out: >link
|
out: >link
|
||||||
out: >name
|
out: >name
|
||||||
out: >body
|
out: >body
|
||||||
|
|
||||||
|
out: current
|
||||||
|
out: #tib
|
||||||
|
out: >in
|
||||||
|
out: state
|
||||||
|
out: base
|
||||||
|
out: context
|
||||||
|
out: latestxt
|
||||||
;e
|
;e
|
||||||
|
|
||||||
e: check-core-opcodes
|
e: check-core-opcodes
|
||||||
|
|||||||
@ -49,19 +49,15 @@ variable scope scope context cell - !
|
|||||||
|
|
||||||
transfer{
|
transfer{
|
||||||
xt-find& xt-hide xt-transfer
|
xt-find& xt-hide xt-transfer
|
||||||
voc-stack-end last-vocabulary
|
voc-stack-end last-vocabulary notfound
|
||||||
'context 'notfound notfound
|
|
||||||
immediate? input-buffer ?echo ?arrow. arrow
|
immediate? input-buffer ?echo ?arrow. arrow
|
||||||
evaluate-buffer
|
evaluate-buffer aliteral
|
||||||
'sys 'heap aliteral 'heap-start 'heap-size
|
|
||||||
'stack-cells 'boot 'boot-size 'latestxt
|
|
||||||
'argc 'argv 'runner 'tib
|
|
||||||
leaving( )leaving leaving leaving,
|
leaving( )leaving leaving leaving,
|
||||||
(do) (?do) (+loop)
|
(do) (?do) (+loop)
|
||||||
parse-quote digit $@ raw.s
|
parse-quote digit $@ raw.s
|
||||||
tib-setup input-limit
|
tib-setup input-limit
|
||||||
[SKIP] [SKIP]' raw-ok
|
[SKIP] [SKIP]' raw-ok
|
||||||
$place zplace sys: BUILTIN_MARK
|
$place zplace BUILTIN_MARK
|
||||||
}transfer
|
}transfer
|
||||||
forth definitions
|
forth definitions
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user