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

add special case for (apply values ...)

* libguile/vm-engine.c (vm_run): Move nvalues to the top level, to avoid
  (spurious, it seems) gcc warnings about it being used uninitialized.

* libguile/vm-i-system.c (halt, return/values): Adapt to gcc silliness.
  Deindent some of return/values.
  (return/values*): New instruction, does what (apply values . args)
  would do.

* module/language/scheme/translate.scm (custom-transformer-table): Move
  the apply and @apply cases here from inline.scm, because we need some
  more cleverness when dealing with cases like (apply values . args).
  (lookup-apply-transformer): Define an eval transformer for `values',
  turning it into ghil-values*.

* module/system/il/compile.scm (codegen): Compile <ghil-values*> into
  return/values*.

* module/system/il/ghil.scm: Add <ghil-values*> and accessors.
  (ghil-lookup): Add optional argument, define?, which if false tells us
  not to actually cache the binding if it is not found in the toplevel.

* module/system/il/inline.scm: Remove apply clauses.

* module/system/vm/frame.scm (bootstrap-frame?): Update heuristic for
  bootstrap-frame?, as the bootstrap frame is now 5 bytes since it
  accepts multiple values.
This commit is contained in:
Andy Wingo 2008-09-15 00:04:34 +02:00
parent a222b0fa91
commit ef24c01bff
7 changed files with 115 additions and 57 deletions

View file

@ -302,10 +302,36 @@
(start-stack
((,tag ,expr) (retrans expr)))
;; FIXME: not hygienic, relies on @apply not being shadowed
(apply
(,args (retrans `(@apply ,@args))))
(@apply
((,proc ,arg1 . ,args)
(let ((args (cons (retrans arg1) (map retrans args))))
(cond ((and (symbol? proc)
(not (ghil-lookup e proc #f))
(and=> (module-variable (current-module) proc)
(lambda (var)
(and (variable-bound? var)
(lookup-apply-transformer (variable-ref var))))))
;; that is, a variable, not part of this compilation
;; unit, but defined in the toplevel environment, and has
;; an apply transformer registered
=> (lambda (t) (t e l args)))
(else (make-ghil-inline e l 'apply
(cons (retrans proc) args)))))))
(values
((,x) (retrans x))
(,args (make-ghil-values e l (map retrans args))))))
(define (lookup-apply-transformer proc)
(cond ((eq? proc values)
(lambda (e l args)
(make-ghil-values* e l args)))
(else #f)))
(define (trans-quasiquote e l x level)
(cond ((not (pair? x)) x)
((memq (car x) '(unquote unquote-splicing))