Add hook mechanism for handling word not found
This commit is contained in:
60
wipforth.wat
60
wipforth.wat
@@ -1119,13 +1119,13 @@
|
|||||||
"\64\05\00\00"
|
"\64\05\00\00"
|
||||||
"\04HERE\00\00\00"
|
"\04HERE\00\00\00"
|
||||||
"\02\00\00\00"
|
"\02\00\00\00"
|
||||||
"\e0\0d\00\00")
|
"\30\0e\00\00")
|
||||||
|
|
||||||
(data (i32.const 0x058c)
|
(data (i32.const 0x058c)
|
||||||
"\78\05\00\00"
|
"\78\05\00\00"
|
||||||
"\06LATEST\00"
|
"\06LATEST\00"
|
||||||
"\02\00\00\00"
|
"\02\00\00\00"
|
||||||
"\b4\0d\00\00")
|
"\e0\0d\00\00")
|
||||||
|
|
||||||
(data (i32.const 0x05a0)
|
(data (i32.const 0x05a0)
|
||||||
"\8c\05\00\00"
|
"\8c\05\00\00"
|
||||||
@@ -1136,9 +1136,9 @@
|
|||||||
|
|
||||||
(data (i32.const 0x05d0)
|
(data (i32.const 0x05d0)
|
||||||
"\a0\05\00\00"
|
"\a0\05\00\00"
|
||||||
"\05ERROR\00\00"
|
"\07WNFHOOK"
|
||||||
"\02\00\00\00"
|
"\01\00\00\00"
|
||||||
"\00\00\00\00")
|
"\f0\0d\00\00")
|
||||||
|
|
||||||
;; And now, it's time for some hand-compiled colon words. It
|
;; And now, it's time for some hand-compiled colon words. It
|
||||||
;; probably would have made more sense to write most of these
|
;; probably would have made more sense to write most of these
|
||||||
@@ -1637,11 +1637,8 @@
|
|||||||
;; LIT-CFA , , \ If compiling, append LIT and the value
|
;; LIT-CFA , , \ If compiling, append LIT and the value
|
||||||
;; EXIT
|
;; EXIT
|
||||||
;;
|
;;
|
||||||
;; \ Word was not found and also not a number. Ideally we'd print the
|
;; \ Word was not found
|
||||||
;; \ word that wasn't found here but I haven't implemented such things
|
;; WNFHOOK EXECUTE
|
||||||
;; \ yet so for now we'll just discard the word's length, set ERROR to
|
|
||||||
;; \ 1 and exit.
|
|
||||||
;; DROP 1 ERROR !
|
|
||||||
;; ;
|
;; ;
|
||||||
|
|
||||||
(data (i32.const 0x0ac0)
|
(data (i32.const 0x0ac0)
|
||||||
@@ -1686,14 +1683,15 @@
|
|||||||
"\5c\0a\00\00" ;; ,
|
"\5c\0a\00\00" ;; ,
|
||||||
"\5c\0a\00\00" ;; ,
|
"\5c\0a\00\00" ;; ,
|
||||||
"\0c\04\00\00" ;; EXIT
|
"\0c\04\00\00" ;; EXIT
|
||||||
"\18\02\00\00" ;; DROP
|
"\dc\05\00\00" ;; WNFHOOK
|
||||||
"\18\04\00\00" ;; LIT
|
"\bc\0b\00\00" ;; EXECUTE
|
||||||
"\01\00\00\00" ;; 1
|
|
||||||
"\dc\05\00\00" ;; ERROR
|
|
||||||
"\c0\03\00\00" ;; !
|
|
||||||
"\0c\04\00\00") ;; EXIT
|
"\0c\04\00\00") ;; EXIT
|
||||||
|
|
||||||
;; => 0xc4 bytes
|
;; => 0xb8 bytes
|
||||||
|
|
||||||
|
;; The previous version of INTERPRET was 0xc4 bytes, so we have 12
|
||||||
|
;; unused bytes here. Could fit an extra codeword definition in
|
||||||
|
;; here, if the name is less than 4 bytes long.
|
||||||
|
|
||||||
;; : QUIT R0 RSP! INTERPRET BRANCH [-8] ;
|
;; : QUIT R0 RSP! INTERPRET BRANCH [-8] ;
|
||||||
|
|
||||||
@@ -1928,7 +1926,7 @@
|
|||||||
;; [
|
;; [
|
||||||
;; ; IMMEDIATE
|
;; ; IMMEDIATE
|
||||||
|
|
||||||
(data (i32.const 0xdb4)
|
(data (i32.const 0x0db4)
|
||||||
"\78\0d\00\00"
|
"\78\0d\00\00"
|
||||||
"\81;\00\00"
|
"\81;\00\00"
|
||||||
"\00\00\00\00"
|
"\00\00\00\00"
|
||||||
@@ -1943,6 +1941,34 @@
|
|||||||
|
|
||||||
;; => 0x2c bytes
|
;; => 0x2c bytes
|
||||||
|
|
||||||
|
;; : WNF-HANDLER
|
||||||
|
;; DROP \ Discard word length
|
||||||
|
;; 87 EMIT 78 EMIT 70 EMIT 10 EMIT \ Print WNF
|
||||||
|
;; QUIT \ Reset return stack
|
||||||
|
;; ;
|
||||||
|
|
||||||
|
(data (i32.const 0x0de0)
|
||||||
|
"\b4\0d\00\00"
|
||||||
|
"\0bWNF-HANDLER"
|
||||||
|
"\00\00\00\00"
|
||||||
|
"\18\02\00\00" ;; DROP
|
||||||
|
"\18\04\00\00" ;; LIT
|
||||||
|
"\57\00\00\00" ;; 87
|
||||||
|
"\94\04\00\00" ;; EMIT
|
||||||
|
"\18\04\00\00" ;; LIT
|
||||||
|
"\4e\00\00\00" ;; 78
|
||||||
|
"\94\04\00\00" ;; EMIT
|
||||||
|
"\18\04\00\00" ;; LIT
|
||||||
|
"\46\00\00\00" ;; 70
|
||||||
|
"\94\04\00\00" ;; EMIT
|
||||||
|
"\18\04\00\00" ;; LIT
|
||||||
|
"\0a\00\00\00" ;; 10
|
||||||
|
"\94\04\00\00" ;; EMIT
|
||||||
|
"\90\0b\00\00" ;; QUIT
|
||||||
|
"\0c\04\00\00") ;; EXIT
|
||||||
|
|
||||||
|
;; => 0x50 bytes
|
||||||
|
|
||||||
;; The trampoline is a workaround for WebAssembly's lack of indirect
|
;; The trampoline is a workaround for WebAssembly's lack of indirect
|
||||||
;; jumps and code addresses. Instead of jumping into the next
|
;; jumps and code addresses. Instead of jumping into the next
|
||||||
;; codeword, NEXT sets the $fn global to the function index of the
|
;; codeword, NEXT sets the $fn global to the function index of the
|
||||||
|
|||||||
Reference in New Issue
Block a user