X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Ftarget-eval.lisp;h=775f6bb2201dc9850d4909e5ef793f1aea83e026;hb=fbe6e22af842835f7c70309f4d48064ca3984ad0;hp=0baf841741fca1974013affc6595bd77d4aed4dc;hpb=cea4896b2482b7b2b429c1631d774b4cfbc0efba;p=sbcl.git diff --git a/src/code/target-eval.lisp b/src/code/target-eval.lisp index 0baf841..775f6bb 100644 --- a/src/code/target-eval.lisp +++ b/src/code/target-eval.lisp @@ -7,28 +7,6 @@ ;;;; provided with absolutely no warranty. See the COPYING and CREDITS ;;;; files for more information. -(in-package "SB!IMPL") - -;;; FIXME: These probably belong in some package other than SB!IMPL. -;;; Perhaps SB!KERNEL? - -(defconstant call-arguments-limit most-positive-fixnum - #!+sb-doc - "The exclusive upper bound on the number of arguments which may be passed - to a function, including rest args.") - -(defconstant lambda-parameters-limit most-positive-fixnum - #!+sb-doc - "The exclusive upper bound on the number of parameters which may be specifed - in a given lambda list. This is actually the limit on required and optional - parameters. With &key and &aux you can get more.") - -(defconstant multiple-values-limit most-positive-fixnum - #!+sb-doc - "The exclusive upper bound on the number of multiple-values that you can - have.") - -;;; FIXME: more than one IN-PACKAGE in one file, ick (in-package "SB!EVAL") ;;; This is defined here so that the printer etc. can call @@ -59,8 +37,8 @@ ;; false, then the function is not in the cache (or is in the process of ;; being removed.) (definition nil :type (or sb!c::clambda null)) - ;; The number of consequtive GCs that this function has been unused. This is - ;; used to control cache replacement. + ;; The number of consecutive GCs that this function has been unused. + ;; This is used to control cache replacement. (gcs 0 :type sb!c::index) ;; True if Lambda has been converted at least once, and thus warnings should ;; be suppressed on additional conversions. @@ -73,18 +51,19 @@ ;;;; One of the steps in building a nice debuggable macro is changing ;;;; its MACRO-FUNCTION to print as e.g. ;;;; # -;;;; instead of some -;;;; weird internal representation showing the environment argument and stuff. -;;;; This function is called in order to try to make that happen. +;;;; instead of some weird internal representation showing the +;;;; environment argument and stuff. This function is called in order +;;;; to try to make that happen. ;;;; -;;;; When we're running in the target SBCL, we own the INTERPRETED-FUNCTION -;;;; definition, and we can do this; that's what the definition below does. -;;;; When we're a Python cross-compiler running in some arbitrary ANSI Common -;;;; Lisp, we can't do this (and we don't care that much about making nice -;;;; debuggable macros anyway). In that environment, a stub no-op version of -;;;; this function is used. +;;;; When we're running in the target SBCL, we own the +;;;; INTERPRETED-FUNCTION definition, and we can do this; that's what +;;;; the definition below does. When we're a Python cross-compiler +;;;; running in some arbitrary ANSI Common Lisp, we can't do this (and +;;;; we don't care that much about making nice debuggable macros +;;;; anyway). In that environment, a stub no-op version of this +;;;; function is used. (defun try-to-rename-interpreted-function-as-macro (f name lambda-list) - (assert (sb!eval:interpreted-function-p f)) + (aver (sb!eval:interpreted-function-p f)) (setf (sb!eval:interpreted-function-name f) (format nil "DEFMACRO ~S" name) (sb!eval:interpreted-function-arglist f) @@ -93,16 +72,17 @@ ;;;; EVAL and friends -;;; This needs to be initialized in the cold load, since the top-level catcher -;;; will always restore the initial value. +;;; This needs to be initialized in the cold load, since the top-level +;;; catcher will always restore the initial value. (defvar *eval-stack-top* 0) ;;; Pick off a few easy cases, and call INTERNAL-EVAL for the rest. If -;;; *ALREADY-EVALED-THIS* is true, then we bind it to NIL before doing a call -;;; so that the effect is confined to the lexical scope of the EVAL-WHEN. +;;; *ALREADY-EVALED-THIS* is true, then we bind it to NIL before doing +;;; a call so that the effect is confined to the lexical scope of the +;;; EVAL-WHEN. (defun eval (original-exp) #!+sb-doc - "Evaluates its single arg in a null lexical environment, returns the + "Evaluates its single argument in a null lexical environment, returns the result or results." (declare (optimize (safety 1))) (let ((exp (macroexpand original-exp))) @@ -140,8 +120,8 @@ ((null name) (do ((args (cdr exp) (cddr args))) ((null (cddr args)) - ;; We duplicate the call to SET so that the correct - ;; value gets returned. + ;; We duplicate the call to SET so that the + ;; correct value gets returned. (set (first args) (eval (second args)))) (set (first args) (eval (second args))))) (let ((symbol (first name))) @@ -178,32 +158,19 @@ (t exp)))) -;;; not needed in new from-scratch cross-compilation procedure -- WHN 19990714 -#| -;;; Dummy stubs for SB!EVAL:INTERNAL-EVAL and SB!EVAL:MAKE-INTERPRETED-FUNCTION -;;; in case the compiler isn't loaded yet. -(defun sb!eval:internal-eval (x) - (error "attempt to evaluation a complex expression:~% ~S~@ - This expression must be compiled, but the compiler is not loaded." - x)) -(defun sb!eval:make-interpreted-function (x) - (error "EVAL called on #'(lambda (x) ...) when the compiler isn't loaded:~ - ~% ~S~%" - x)) -|# - +;;; Given a function, return three values: +;;; 1] A lambda expression that could be used to define the function, +;;; or NIL if the definition isn't available. +;;; 2] NIL if the function was definitely defined in a null lexical +;;; environment, and T otherwise. +;;; 3] Some object that \"names\" the function. Although this is +;;; allowed to be any object, CMU CL always returns a valid +;;; function name or a string. +;;; ;;; If interpreted, use the interpreter interface. Otherwise, see ;;; whether it was compiled with COMPILE. If that fails, check for an ;;; inline expansion. (defun function-lambda-expression (fun) - #!+sb-doc - "Given a function, return three values: - 1] A lambda expression that could be used to define the function, or NIL if - the definition isn't available. - 2] NIL if the function was definitely defined in a null lexical environment, - and T otherwise. - 3] Some object that \"names\" the function. Although this is allowed to be - any object, CMU CL always returns a valid function name or a string." (declare (type function fun)) (if (sb!eval:interpreted-function-p fun) (sb!eval:interpreted-function-lambda-expression fun)