1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-14 23:50:19 +02:00

peval: Recognize module-refs to primitives.

* module/language/tree-il/optimize.scm (peval): Handle module-refs to
  primitives.

* test-suite/tests/tree-il.test ("partial evaluation"): Add test, using
  `pmatch'.
This commit is contained in:
Ludovic Courtès 2011-09-23 17:27:28 +02:00
parent 014de9e25d
commit 16d50b8e89
2 changed files with 22 additions and 0 deletions

View file

@ -708,6 +708,15 @@ it does not handle <fix> and <let-values>, it should be called before
(($ <toplevel-ref>)
;; todo: open private local bindings.
exp)
(($ <module-ref> src module (? effect-free-primitive? name) #f)
(let ((module (false-if-exception
(resolve-module module #:ensure #f))))
(if (module? module)
(let ((var (module-variable module name)))
(if (eq? var (module-variable the-scm-module name))
(make-primitive-ref src name)
exp))
exp)))
(($ <module-ref>)
exp)
(($ <module-set> src mod name public? exp)