forge: lit (instead of comp) for moving top stack element to compile buffer

This commit is contained in:
Helmut Merz 2026-02-13 21:30:29 +01:00
parent a76f59498c
commit b6ed8805e4
3 changed files with 10 additions and 3 deletions

7
forge/basic.frg Normal file
View file

@ -0,0 +1,7 @@
; basic.frg
(dup mul) comp in square reg
(comp in reg) comp in def reg
(dup dup mul mul) def cube

View file

@ -163,7 +163,7 @@
#:? #:??
#:ptr #:get #:put
#:in #:next
#:call #:call-if #:call-while #:comp #:val
#:call #:call-if #:call-while #:lit #:val
#:<comp #:reg #:regc #:/>))
(in-package :sf-builtin)
@ -200,10 +200,10 @@
(f:reg 'in #'(lambda () (f:pushd (iter:next-value f:*input*))))
(f:reg 'next #'f:next)
(f:reg 'comp #'(lambda () (cons (f:popd) f::*buffer*)))
(f:reg 'call #'(lambda () (f:call (f:popd))))
(f:reg 'call-if #'call-if)
(f:reg 'call-while #'call-while)
(f:reg 'lit #'(lambda () (cons (f:popd) f::*buffer*)))
(f:reg 'val #'(lambda () (f:pushd (list #'f:next (f:popd)))))
(f:reg '<comp #'f:comp-input)

View file

@ -57,4 +57,4 @@
(deftest test-if ()
(forge:exec-list '(<comp in <comp swp reg /> in <defc regc))
(forge:exec-list '(<defc <if <comp next next comp comp next call-if comp />)))
(forge:exec-list '(<defc <if <comp next next lit lit next call-if lit />)))