summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkitty <nepeta@canaglie.net>2026-03-08 15:42:53 +1100
committerkitty <nepeta@canaglie.net>2026-03-08 15:42:53 +1100
commit9014dde6d62d7d37e3ccb050608db15ed9930b49 (patch)
tree10d93e5312b441c92d6a390cdf0820c37dc3c7dd
parentee64f10b64c6efc20fe9f2e457f2e872ca56ca52 (diff)
new error: includes too recursed
-rw-r--r--jefs.fs15
-rw-r--r--readme.md4
2 files changed, 13 insertions, 6 deletions
diff --git a/jefs.fs b/jefs.fs
index 6b631a2..f9eba09 100644
--- a/jefs.fs
+++ b/jefs.fs
@@ -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
diff --git a/readme.md b/readme.md
index 737def3..fec9526 100644
--- a/readme.md
+++ b/readme.md
@@ -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