diff options
| -rw-r--r-- | jefs.fs | 15 | ||||
| -rw-r--r-- | readme.md | 4 |
2 files changed, 13 insertions, 6 deletions
@@ -47,7 +47,6 @@ hex : ret, c3 c, ; decimal : constant create [compile] lit ret, ; : variable 1 cells allot@ create [compile] lit ret, ; \ maybe i made bad design decisions, this is CREATE but it pushes a pointer to just after its definition. for arrays and the like -\ does not use LIT because we want to fill it in After : make create here @ 18 + [compile] lit ret, ; 0 constant false @@ -130,7 +129,7 @@ variable disp : modrm, modrm @ c, disp @ ?dup 0<> if c, then ; : mod0 modrm @ 3f and modrm ! ; -: d) dup disp ! mod0 0<> if modrm @ 40 or modrm ! then ; \ disp8 or 0 only for now. bug TODO: doesn't put correct .mod bytes +: d) dup disp ! mod0 0<> if modrm @ 40 or modrm ! then ; \ disp8 or 0 only for now. : disp, disp @ ?dup 0<> if c, then ; : mov, rex, 8b c, modrm @ c, disp, asm$ ; @@ -239,7 +238,7 @@ decimal : .free bytes-free u. ." of " bytes-allocated u. ." bytes free (used " bytes-used (.) say ." )" cr ; \ }}} -5 constant #error-msgs +6 constant #error-msgs make error-msgs #error-msgs cells allot : set-error ( xt -- ) cells error-msgs + ! ; : write-error cells error-msgs + @ execute ; @@ -248,6 +247,7 @@ make error-msgs #error-msgs cells allot :> ." word not found" ; 2 set-error :> ." compile mode only" ; 3 set-error :> ." interpret mode only" ; 4 set-error +:> ." includes too recursed" ; 5 set-error \ awful description : #bye ( code -- ) 60 syscall1 ; \ maybe this would be more elegant as a table? @@ -341,12 +341,19 @@ make line-buffer line-buffer-length allot \ todo?: reset retstack : quit 0 to source-id [compile] [ begin refill while interpret ." ok" cr repeat ; :> >s0 error @ write-error cr quit ; to handler -\ }}} : (evaluate) ( c-addr u -- ) 0 >in ! ( u ) #tib ! ( c-addr ) tib ! source-id >r string-source to source-id interpret r> to source-id ; : evaluate ( c-addr u -- ) tib @ >r #tib @ >r >in @ >r (evaluate) r> >in ! r> #tib ! r> tib ! ; +: ?inc-depth include-depth max-include-depth > if 0 to include-depth 5 fuck then ; +: include-file tib @ >r #tib @ >r >in @ >r source-id >r 1 +to include-depth + ?inc-depth + 1 -to include-depth >r >in ! >r #tib ! >r tib ! r> to source-id ; +: included ; +: include ; +\ }}} + \ TERMINAL CONTROL {{{ 60 constant termios# make termios termios# allot @@ -13,7 +13,7 @@ i am thinking of completing before that. - `s\"` - `DO` + `LOOP` -- `\<BUILDS` and `DOES>` +- `<BUILDS` and `DOES>` - reading from files - argc + argv - testing @@ -64,8 +64,8 @@ and `execute`ing it. the actual description of the error comes from the the error codes are: -- 0: nothing. - 1: stack underflow - 2: word not found - 3: compilation only - 4: interpret only +- 5: includes too recursed |
