forge/sf: val (pushing code directly to stack) as basis for const and var

This commit is contained in:
Helmut Merz 2024-09-17 08:45:17 +02:00
parent 62350964c6
commit 6bf62fa39d
2 changed files with 7 additions and 2 deletions

View file

@ -135,7 +135,7 @@
(car (stack *forge-env*)))
(defun next ()
(pushd (iter:next-value *code*)))
(pushd (pop *code*)))
;;;; builtins
@ -149,7 +149,7 @@
#:ptr #:get #:put
#:in #:next
#:call #:call-if #:call-while #:comp
#:<comp #:reg #:regc #:/>))
#:<comp #:reg #:regc #:/> #:val))
(in-package :sf-builtin)
@ -197,4 +197,6 @@
(f:reg '/> #'(lambda () (iter:stop f:*input*)) 'f:comp-word)
(f:reg 'val #'(lambda () (f:pushd (list #'f:next (f:popd)))))
;;;; forge-code word definitions

View file

@ -37,3 +37,6 @@
(forge:exec-string "<def cube dup dup mul mul />")
(forge:exec-list '(3 cube))
(== (forge:popd) 27))
(deftest test-val ()
(forge:exec-list '(<def const val in reg />)))