- Evaluate the Forms in the specified Situations, any of COMPILE, LOAD, EVAL.
- This is conceptually a compile-only implementation, so EVAL is a no-op."
-
- ;; It's difficult to handle EVAL-WHENs completely correctly in the
- ;; cross-compiler. (Common Lisp is not a cross-compiler-friendly
- ;; language..) Since we, the system implementors, control not only
- ;; the cross-compiler but also the code that it processes, we can
- ;; handle this either by making the cross-compiler smarter about
- ;; handling EVAL-WHENs (hard) or by avoiding the use of difficult
- ;; EVAL-WHEN constructs (relatively easy). However, since EVAL-WHENs
- ;; can be generated by many macro expansions, it's not always easy
- ;; to detect problems by skimming the source code, so we'll try to
- ;; add some code here to help out.
- ;;
- ;; Nested EVAL-WHENs are tricky.
- #+sb-xc-host
- (labels ((contains-toplevel-eval-when-p (body-part)
- (and (consp body-part)
- (or (eq (first body-part) 'eval-when)
- (and (member (first body-part)
- '(locally macrolet progn symbol-macrolet))
- (some #'contains-toplevel-eval-when-p
- (rest body-part)))))))
- (/show "testing for nested EVAL-WHENs" body)
- (when (some #'contains-toplevel-eval-when-p body)
- (compiler-style-warning "nested EVAL-WHENs in cross-compilation")))
-
- (do-eval-when-stuff situations
- body
- (lambda (forms)
- (ir1-convert-progn-body start cont forms))))
-
-;;; Like DO-EVAL-WHEN-STUFF, only do a MACROLET. FUN is not passed any
-;;; arguments.
-(defun do-macrolet-stuff (definitions fun)
- (declare (list definitions) (type function fun))
- (let ((whole (gensym "WHOLE"))
- (environment (gensym "ENVIRONMENT")))
- (collect ((new-fenv))
- (dolist (def definitions)
- (let ((name (first def))
- (arglist (second def))
- (body (cddr def)))
- (unless (symbolp name)
- (compiler-error "The local macro name ~S is not a symbol." name))
- (when (< (length def) 2)
- (compiler-error
- "The list ~S is too short to be a legal local macro definition."
- name))
- (multiple-value-bind (body local-decs)
- (parse-defmacro arglist whole body name 'macrolet
- :environment environment)
- (new-fenv `(,(first def) macro .
- ,(coerce `(lambda (,whole ,environment)
- ,@local-decs (block ,name ,body))
- 'function))))))
-
- (let ((*lexenv* (make-lexenv :functions (new-fenv))))
- (funcall fun))))
-