From 543bd697f69636cd67d15ac019c6dfe26df1002c Mon Sep 17 00:00:00 2001 From: kitty Date: Mon, 2 Mar 2026 00:25:21 +1100 Subject: true+false, unfinished REFILL cant be bothered to finish it right now --- jefs.fs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/jefs.fs b/jefs.fs index 746b5be..e1b4853 100644 --- a/jefs.fs +++ b/jefs.fs @@ -88,6 +88,9 @@ hex : ret, c3 c, ; decimal \ also we can't use CREATE because it reads from tib. eugh : :> here @ latest @ , 0 c, 1 w, [ char _ ] literal c, latest ! smudge here @ ( ← xt ) [compile] ] ; +0 constant false +-1 constant true + \ jonesforth impl : case 0 ; immediate : of ' over compile, ' = compile, [compile] if ' drop compile, ; immediate @@ -169,6 +172,7 @@ decimal : mod /mod drop ; : negate 0 swap - ; : abs dup 0< if negate then ; +\ i don't know how to implement these correctly with 64 bit single cells : */mod >r * r> /mod ; : */ */mod nip ; : % 100 */ ; @@ -260,9 +264,7 @@ variable hld 1 constant w/o 2 constant r/w -\ TODO error handling (0< abs → errno i think) -\ flags are zero on success -\ maybe there should be some sort of read buffering support here +\ todo do these return the right values? (true instead of false?) : open-file ( mode zstr -- ?fd flag ) 0 -rot sysopen errno ; : close-file ( fd -- flag ) sysclose errno-flag ; : read-file ( c-addr u fd -- ?u flag ) >r swap r> sysread errno ; @@ -277,12 +279,20 @@ variable source-id init-source source-id ! 8192 constant file-buffer-length +variable file-buffer-used make file-buffer file-buffer-length allot + +\ todo move remaining stuff back before read-file, +\ update tib stuff for new data +: (refill) ( fd -- flag ) >r file-buffer file-buffer-length r> read-file + 0= if ?dup 0> if ( TODO > ) drop ( < TODO ) + else false then else false then ; +: refill ( -- flag ) source-id @ dup 0>= if (refill) else drop false then ; +: refill ." UNIMPLEMENTED" cr ; \ }}} : (evaluate) ( c-addr u -- ) 0 >in ! ( u ) #tib ! ( c-addr ) tib ! - source-id @ >r string-source source-id ! interpret - r> source-id ! ; + source-id @ >r string-source source-id ! interpret r> source-id ! ; : evaluate ( c-addr u -- ) tib @ >r #tib @ >r >in @ >r (evaluate) r> >in ! r> #tib ! r> tib ! ; \ INTERACTIVITY {{{ -- cgit v1.2.3