Changeset 11920


Ignore:
Timestamp:
05/21/09 21:16:30 (12 years ago)
Author:
ehuelsmann
Message:

Enable precompilation of functions in a non-null
lexical environment, now that the precompiler
doesn't keep state outside the Environment anyway.

Enables (amongst others):
(symbol-macrolet ((b y))

(defun foo ()

(let (y)

b)))

(precompile 'foo)

File:
1 edited

Legend:

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

    r11919 r11920  
    529529            (if expanded
    530530                (precompile1 (list 'SETF expansion val))
    531                 (list 'SETQ sym (precompile1 val))
    532                 )))
     531                (list 'SETQ sym (precompile1 val)))))
    533532        (let ((result ()))
    534533          (loop
     
    10311030    (setq definition (or (and (symbolp name) (macro-function name))
    10321031                         (fdefinition name))))
    1033   (let (expr result
     1032  (let ((expr definition)
     1033        env result
    10341034        (pre::*precompile-env* nil))
    1035     (cond ((functionp definition)
    1036            (multiple-value-bind (form closure-p)
    1037              (function-lambda-expression definition)
    1038              (unless form
    1039 ;;                (format t "; No lambda expression available for ~S.~%" name)
    1040                (return-from precompile (values nil t t)))
    1041              (when closure-p
    1042                (format t "; Unable to compile function ~S defined in non-null lexical environment.~%" name)
    1043                (finish-output)
    1044                (return-from precompile (values nil t t)))
    1045              (setq expr form)))
    1046           ((and (consp definition) (eq (%car definition) 'lambda))
    1047            (setq expr definition))
    1048           (t
    1049 ;;            (error 'type-error)))
    1050            (format t "Unable to precompile ~S.~%" name)
    1051            (return-from precompile (values nil t t))))
    1052     (setf result (coerce-to-function (precompiler:precompile-form expr nil)))
     1035    (when (functionp definition)
     1036      (multiple-value-bind (form closure-p)
     1037          (function-lambda-expression definition)
     1038        (unless form
     1039          (return-from precompile (values nil t t)))
     1040        (setq env closure-p)
     1041        (setq expr form)))
     1042    (unless (and (consp expr) (eq (car expr) 'lambda))
     1043      (format t "Unable to precompile ~S.~%" name)
     1044      (return-from precompile (values nil t t)))
     1045    (setf result
     1046          (sys:make-closure (precompiler:precompile-form expr nil env) env))
    10531047    (when (and name (functionp result))
    10541048      (sys::set-function-definition name result definition))
Note: See TracChangeset for help on using the changeset viewer.