diff options
| author | kitty <nepeta@canaglie.net> | 2026-03-02 00:25:21 +1100 |
|---|---|---|
| committer | kitty <nepeta@canaglie.net> | 2026-03-02 00:25:21 +1100 |
| commit | 543bd697f69636cd67d15ac019c6dfe26df1002c (patch) | |
| tree | 0c2c4ef6656f2170ec8f5ad202e80c7b3b450d05 /jefs.fs | |
| parent | 7ba683f7bec77ed008aeb3b25aaafd9e9d27f50d (diff) | |
true+false, unfinished REFILL
cant be bothered to finish it right now
Diffstat (limited to 'jefs.fs')
| -rw-r--r-- | jefs.fs | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -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 {{{ |
