Changeset 12340


Ignore:
Timestamp:
01/06/10 22:10:33 (12 years ago)
Author:
ehuelsmann
Message:

Fix symbol-macrolet expanding variables declared in
a lambda-list for LAMBDA and NAMED-LAMBDA forms.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/precompiler.lisp

    r12326 r12340  
    570570             (push new-arg new))))))
    571571
     572(defun extract-lambda-vars (lambda-list)
     573  (let ((state :required)
     574        vars)
     575    (dolist (var/key lambda-list vars)
     576      (cond
     577        ((eq '&aux var/key)       (setf state :aux))
     578        ((eq '&key var/key)       (setf state :key))
     579        ((eq '&optional var/key)  (setf state :optional))
     580        ((eq '&rest var/key)      (setf state :rest))
     581        ((symbolp var/key)        (unless (eq var/key '&allow-other-keys)
     582                                    (push var/key vars)))
     583        ((and (consp var/key)
     584              (member state '(:optional :key)))
     585         (setf var/key (car var/key))
     586         (when (and (consp var/key) (eq state :key))
     587           (setf var/key (second var/key)))
     588         (if (symbolp var/key)
     589             (push var/key vars)
     590             (error 'program-error
     591                    :format-control
     592                    "Unexpected ~A variable specifier ~A."
     593                    :format-arguments (list state var/key))))
     594        ((and (consp var/key) (eq state :aux))
     595         (if (symbolp (car var/key))
     596             (push (car var/key) vars)
     597             (error 'program-error
     598                    :format-control "Unexpected &AUX format for ~A."
     599                    :format-arguments (list var/key))))
     600        (t
     601         (error 'program-error
     602                :format-control "Unexpected lambda-list format: ~A."
     603                :format-arguments (list lambda-list)))))))
     604
    572605(defun precompile-lambda (form)
    573606  (let ((body (cddr form))
    574607        (precompiled-lambda-list
    575608           (precompile-lambda-list (cadr form)))
    576         (*inline-declarations* *inline-declarations*))
     609        (*inline-declarations* *inline-declarations*)
     610        (*precompile-env* (make-environment *precompile-env*)))
    577611    (process-optimization-declarations body)
     612    (dolist (var (extract-lambda-vars precompiled-lambda-list))
     613      (environment-add-symbol-binding *precompile-env* var nil))
    578614    (list* 'LAMBDA precompiled-lambda-list
    579615           (mapcar #'precompile1 body))))
     
    584620          (precompiled-lambda-list
    585621           (precompile-lambda-list (cadr lambda-form)))
    586           (*inline-declarations* *inline-declarations*))
     622          (*inline-declarations* *inline-declarations*)
     623          (*precompile-env* (make-environment *precompile-env*)))
    587624      (process-optimization-declarations body)
     625      (dolist (var (extract-lambda-vars precompiled-lambda-list))
     626        (environment-add-symbol-binding *precompile-env* var nil))
    588627      (list* 'NAMED-LAMBDA (cadr form) precompiled-lambda-list
    589628             (mapcar #'precompile1 body)))))
Note: See TracChangeset for help on using the changeset viewer.