duskos

dusk os fork
git clone git://git.alexwennerberg.com/duskos
Log | Files | Refs | README | LICENSE

commit 981cd25b7a2034c60d94ac30d5c6d21d9a6debbe
parent 07281f1492dedac922415e4f135150d176fade97
Author: binarycat <binarycat@envs.net>
Date:   Sun, 10 Jul 2022 12:10:12 -0400

inline variant of with

add "with[" "]with" and "ahead"

Diffstat:
Mfs/lib/with.fs | 5++++-
Mfs/tests/lib/with.fs | 3+++
Mfs/xcomp/bootlo.fs | 1+
3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/fs/lib/with.fs b/fs/lib/with.fs @@ -1,3 +1,6 @@ \\ helper word to save and restore a variable across a function call. : with ( w u addr -- ) dup >r dup @ >r ! execute r> r> ! ; - +\ inline variant of with +\ ( u addr ) with[ ... ]with +: with[ [compile] ahead here swap ; immediate +: ]with exit, [compile] then litn compile rot> compile with ; immediate diff --git a/fs/tests/lib/with.fs b/fs/tests/lib/with.fs @@ -6,4 +6,7 @@ create cell1 7 , : foo cell1 @ 55 #eq ; : bar ['] foo 55 cell1 with ; bar cell1 @ 7 #eq +: _ 0 cell1 with[ 77 . ]with ; _ +: baz $77 cell1 with[ cell1 @ $77 #eq $99 cell1 ! ]with cell1 @ 7 #eq 8 cell1 ! ; +baz cell1 @ 8 #eq testend diff --git a/fs/xcomp/bootlo.fs b/fs/xcomp/bootlo.fs @@ -5,6 +5,7 @@ : to' ['] noop [to] ; : compile ' litn ['] execute, execute, ; immediate : if compile (?br) here 4 allot ; immediate +: ahead compile (br) here 4 allot ; immediate : then here swap ! ; immediate : else compile (br) here 4 allot here rot ! ; immediate : begin here ; immediate