commit aff76d0e0766f79f0b4e79d73cdcd61207c5f186
parent 4bebaabd8745469e415f3e8d30fa52d763ad6b01
Author: binarycat <binarycat@envs.net>
Date: Fri, 8 Jul 2022 11:20:43 -0400
print backtrace on error
add ".btrace" and "unaliases", change the behavior of "word?"
Diffstat:
6 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/dusk.asm b/dusk.asm
@@ -69,6 +69,7 @@ curword: resb 0x20 ; 1b len, then contents
inrd: resd 1 ; in<
emit: resd 1
main: resd 1
+abort: resd 1
resd PS_SZ
ps_top:
resd RS_SZ
@@ -92,6 +93,7 @@ _start:
mov dword [main], word_mainloop
mov dword [inrd], word_bootrd
mov dword [emit], word__emit
+ mov dword [abort], word__abort
jmp word_abort
firstword 'bye', 3, word_bye
@@ -111,7 +113,7 @@ defword 'quit', 4, word_quit
mov esp, rs_top
jmp word_main
-defword 'abort', 5, word_abort
+defword '(abort)', 7, word__abort
test byte [exitonabort], -1
jz _abort_no_exit
mov eax, SYSCALL_EXIT
@@ -121,6 +123,9 @@ _abort_no_exit:
mov ebp, ps_top
jmp word_quit
+defword 'abort', 5, word_abort
+ sysalias abort
+
defword 'exitonabort', 11, word_exitonabort
mov byte [exitonabort], 1
ret
diff --git a/fs/init.fs b/fs/init.fs
@@ -13,5 +13,6 @@ f<< lib/nfmt.fs
f<< lib/diag.fs
f<< sys/xhere.fs
f<< sys/rdln.fs
+f<< lib/btrace.fs
: init S" Dusk OS" stype nl> .free rdln$ ;
init
diff --git a/fs/lib/btrace.fs b/fs/lib/btrace.fs
@@ -0,0 +1,6 @@
+?f<< lib/dict.fs
+?f<< lib/nfmt.fs
+: raddr>entry ( a -- w ) current begin 2dup < while prevword repeat nip ;
+: .raddr ( a -- ) dup .x raddr>entry ?dup if spc> .word then ;
+: .btrace nl> begin rcnt while r> .raddr nl> repeat unaliases abort ;
+' .btrace to abort
diff --git a/fs/lib/dict.fs b/fs/lib/dict.fs
@@ -5,7 +5,7 @@
: wordname[] ( w -- sa sl )
dup wordlen swap 5 - over - ( sl sa ) swap ;
-: word? ( w -- f ) wordname[] if c@ 127 = not else drop 0 then ;
+: word? ( w -- f ) dup if wordname[] if c@ 127 = not else drop 0 then then ;
: (prevword) ( w -- w ) begin dup while dup word? not while preventry repeat then ;
: prevword ( w -- w ) preventry (prevword) ;
: lastword ( -- w ) current (prevword) ;
diff --git a/fs/sys/rdln.fs b/fs/sys/rdln.fs
@@ -20,5 +20,8 @@ in) value in>
: rdln< ( -- c ) rdln<? ?dup not if
rdln in( to in> SPC then ;
: rdln$ ['] rdln< to in< in) to in> ;
-: _ rdln$ mainloop ;
+
+: _ rdln$ unaliases main ;
' _ to main
+
+
diff --git a/fs/xcomp/bootlo.fs b/fs/xcomp/bootlo.fs
@@ -107,3 +107,7 @@ alias else endof immediate
\ doc comment placeholder
alias \ \\
+
+\ words for alias chaining
+: unaliases ' to' execute @ execute, ; immediate
+