X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Ffull-eval.lisp;h=08f8cb667b3955eac4f982857ee757ee78015045;hb=HEAD;hp=718f5f13c33981a3abdc64ffbfcfc1f179410a6f;hpb=709547dfb0905983f23bf131c43affe7788a7e9f;p=sbcl.git diff --git a/src/code/full-eval.lisp b/src/code/full-eval.lisp index 718f5f1..08f8cb6 100644 --- a/src/code/full-eval.lisp +++ b/src/code/full-eval.lisp @@ -357,9 +357,10 @@ ;;; Evaluate LET*-like (sequential) bindings. ;;; ;;; Given an alist of BINDINGS, evaluate the value form of the first -;;; binding in ENV, bind the variable to the value in ENV, and then -;;; evaluate the next binding form. Once all binding forms have been -;;; handled, END-ACTION is funcalled. +;;; binding in ENV, generate an augmented environment with a binding +;;; of the variable to the value in ENV, and then evaluate the next +;;; binding form. Once all binding forms have been handled, END-ACTION +;;; is funcalled with the final environment. ;;; ;;; SPECIALS is a list of variables that have a bound special declaration. ;;; These variables (and those that have been declaimed as special) are @@ -373,20 +374,21 @@ (%eval exp env)))) (if bindings (let* ((binding-name (car (car bindings))) - (binding-value (cdr (car bindings)))) + (binding-value (cdr (car bindings))) + (new-env (make-env :parent env))) (if (specialp binding-name specials) (progv (list binding-name) (list (maybe-eval binding-value)) ;; Mark the variable as special in this environment - (push-var binding-name *special* env) - (eval-next-let*-binding (cdr bindings) - specials env end-action)) + (push-var binding-name *special* new-env) + (eval-next-let*-binding + (cdr bindings) specials new-env end-action)) (progn - (push-var binding-name (maybe-eval binding-value) env) - (eval-next-let*-binding (cdr bindings) - specials env end-action)))) - (funcall end-action)))) + (push-var binding-name (maybe-eval binding-value) new-env) + (eval-next-let*-binding + (cdr bindings) specials new-env end-action)))) + (funcall end-action env)))) ;;; Create a new environment based on OLD-ENV by adding the variable ;;; bindings in BINDINGS to it, and call FUNCTION with the new environment @@ -461,7 +463,7 @@ ;; Then deal with optionals / keywords / etc. (eval-next-let*-binding let*-like-binding var-specials env - #'(lambda () + #'(lambda (env) ;; And now that we have evaluated all the ;; initialization forms for the bindings, add the free ;; special declarations to the environment. To see why @@ -522,9 +524,7 @@ (t (values (cdr binding) :variable))) (case (sb!int:info :variable :kind symbol) (:macro (values (macroexpand-1 symbol) :expansion)) - (:alien (let ((type (sb!int:info :variable :alien-info symbol))) - (values (sb!alien::%heap-alien type) - :variable))) + (:alien (values (sb!alien-internals:alien-value symbol) :variable)) (t (values (symbol-value symbol) :variable)))))) ;;; Retrieve the function/macro binding of the symbol NAME in @@ -648,7 +648,7 @@ (binding-value binding))) bindings) var-specials env - #'(lambda () + #'(lambda (env) ;; Now that we're done evaluating the bindings, add the ;; free special declarations. See also ;; CALL-WITH-NEW-ENV-FULL-PARSING. @@ -1186,27 +1186,16 @@ (defun eval-in-native-environment (form lexenv) (handler-bind ((sb!impl::eval-error - (lambda (condition) - (error 'interpreted-program-error - :condition (sb!int:encapsulated-condition condition) - :form form))) - (sb!c:compiler-error - (lambda (c) - (if (boundp 'sb!c::*compiler-error-bailout*) - ;; if we're in the compiler, delegate either to a higher - ;; authority or, if that's us, back down to the - ;; outermost compiler handler... - (progn - (signal c) - nil) - ;; ... if we're not in the compiler, better signal the - ;; error straight away. - (invoke-restart 'sb!c::signal-error))))) - (handler-case - (let ((env (make-env-from-native-environment lexenv))) - (%eval form env)) - (compiler-environment-too-complex-error (condition) - (declare (ignore condition)) - (sb!int:style-warn 'sb!kernel:lexical-environment-too-complex - :form form :lexenv lexenv) - (sb!int:simple-eval-in-lexenv form lexenv))))) + (lambda (condition) + (error 'interpreted-program-error + :condition (sb!int:encapsulated-condition condition) + :form form)))) + (sb!c:with-compiler-error-resignalling + (handler-case + (let ((env (make-env-from-native-environment lexenv))) + (%eval form env)) + (compiler-environment-too-complex-error (condition) + (declare (ignore condition)) + (sb!int:style-warn 'sb!kernel:lexical-environment-too-complex + :form form :lexenv lexenv) + (sb!int:simple-eval-in-lexenv form lexenv))))))