Changeset 13494 for trunk/abcl/src/org


Ignore:
Timestamp:
08/14/11 13:19:32 (10 years ago)
Author:
ehuelsmann
Message:

Only evaluate atoms in the input stream once.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/compile-file.lisp

    r13493 r13494  
    391391(declaim (ftype (function (t stream t) t) process-toplevel-form))
    392392(defun process-toplevel-form (form stream compile-time-too)
    393   (if (atom form)
    394       (when compile-time-too
    395         (eval form))
    396     (progn
    397       (let* ((operator (%car form))
    398              (handler (get operator 'toplevel-handler)))
    399         (when handler
    400           (let ((out-form (funcall handler form stream compile-time-too)))
    401             (when out-form
    402               (output-form out-form)))
    403           (return-from process-toplevel-form))
    404         (when (and (symbolp operator)
    405                    (macro-function operator *compile-file-environment*))
    406           (note-toplevel-form form)
    407           ;; Note that we want MACROEXPAND-1 and not MACROEXPAND here, in
    408           ;; case the form being expanded expands into something that needs
    409           ;; special handling by PROCESS-TOPLEVEL-FORM (e.g. DEFMACRO).
    410           (let ((*compile-print* nil))
    411             (process-toplevel-form (macroexpand-1 form *compile-file-environment*)
    412                                    stream compile-time-too))
    413           (return-from process-toplevel-form))
    414 
    415         (cond
    416           ((and (symbolp operator)
    417                 (not (special-operator-p operator))
    418                 (null (cdr form)))
    419            (setf form (precompiler:precompile-form form nil
    420                                                    *compile-file-environment*)))
    421           (t
    422            (note-toplevel-form form)
    423            (setf form (convert-toplevel-form form nil)))))))
    424   (when (consp form)
    425     (output-form form))
     393  (unless (atom form)
     394    (let* ((operator (%car form))
     395           (handler (get operator 'toplevel-handler)))
     396      (when handler
     397        (let ((out-form (funcall handler form stream compile-time-too)))
     398          (when out-form
     399            (output-form out-form)))
     400        (return-from process-toplevel-form))
     401      (when (and (symbolp operator)
     402                 (macro-function operator *compile-file-environment*))
     403        (note-toplevel-form form)
     404        ;; Note that we want MACROEXPAND-1 and not MACROEXPAND here, in
     405        ;; case the form being expanded expands into something that needs
     406        ;; special handling by PROCESS-TOPLEVEL-FORM (e.g. DEFMACRO).
     407        (let ((*compile-print* nil))
     408          (process-toplevel-form (macroexpand-1 form *compile-file-environment*)
     409                                 stream compile-time-too))
     410        (return-from process-toplevel-form))
     411
     412      (cond
     413        ((and (symbolp operator)
     414              (not (special-operator-p operator))
     415              (null (cdr form)))
     416         (setf form (precompiler:precompile-form form nil
     417                                                 *compile-file-environment*)))
     418        (t
     419         (note-toplevel-form form)
     420         (setf form (convert-toplevel-form form nil)))))
     421    (when (consp form)
     422      (output-form form)))
    426423  ;; Make sure the compiled-function loader knows where
    427424  ;; to load the compiled functions. Note that this trickery
Note: See TracChangeset for help on using the changeset viewer.