mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-28 16:00:22 +02:00
peval: elide make-prompt-tag in effect context
* module/language/tree-il/optimize.scm (peval): Fix a duplicate traversal for constructors in effect or test context. Add support for eliding make-prompt-tag. * test-suite/tests/tree-il.test ("partial evaluation"): Update the test for make-prompt-tag elision.
This commit is contained in:
parent
ea726a53b2
commit
6c4ffe2b25
2 changed files with 17 additions and 7 deletions
|
@ -769,8 +769,7 @@ it does not handle <fix> and <let-values>, it should be called before
|
|||
(($ <primitive-ref> _ (? constructor-primitive? name))
|
||||
(case ctx
|
||||
((effect test)
|
||||
(let ((exp (for-value exp))
|
||||
(res (if (eq? ctx 'effect)
|
||||
(let ((res (if (eq? ctx 'effect)
|
||||
(make-void #f)
|
||||
(make-const #f #t))))
|
||||
(match (for-value exp)
|
||||
|
@ -783,7 +782,12 @@ it does not handle <fix> and <let-values>, it should be called before
|
|||
(($ <application> _ ($ <primitive-ref> _ 'vector) elts)
|
||||
(for-tail
|
||||
(make-sequence src (append elts (list res)))))
|
||||
(_ exp))))
|
||||
(($ <application> _ ($ <primitive-ref> _ 'make-prompt-tag) ())
|
||||
res)
|
||||
(($ <application> _ ($ <primitive-ref> _ 'make-prompt-tag)
|
||||
(($ <const> _ (? string?))))
|
||||
res)
|
||||
(exp exp))))
|
||||
(else
|
||||
(match (cons name (map for-value orig-args))
|
||||
(('cons head tail)
|
||||
|
|
|
@ -1282,10 +1282,16 @@
|
|||
(call-with-prompt tag
|
||||
(lambda () 1)
|
||||
(lambda args args)))
|
||||
;; FIXME: elide the (make-prompt-tag) call
|
||||
(begin
|
||||
(apply (primitive make-prompt-tag))
|
||||
(const 1)))
|
||||
(const 1))
|
||||
|
||||
(pass-if-peval
|
||||
resolve-primitives
|
||||
;; Prompt is removed if tag is unreferenced, with explicit stem
|
||||
(let ((tag (make-prompt-tag "foo")))
|
||||
(call-with-prompt tag
|
||||
(lambda () 1)
|
||||
(lambda args args)))
|
||||
(const 1))
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue