From 3352db3a8b45bc544473915ef25a4708f386be36 Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Sat, 31 Mar 2012 11:48:13 +0300 Subject: [PATCH] sb-alien-internals: ALIEN-VALUE to extract value of a symbol bound to an alien Used in the evaluators. Also allows the simple evaluator to process alien variables without invoking the compiler. --- src/code/eval.lisp | 2 +- src/code/full-eval.lisp | 4 +--- src/code/target-alieneval.lisp | 8 ++++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/code/eval.lisp b/src/code/eval.lisp index 1839520..cafbb1c 100644 --- a/src/code/eval.lisp +++ b/src/code/eval.lisp @@ -162,7 +162,7 @@ ;; with DEFINE-SYMBOL-MACRO, keeping the code walkers ;; happy. (:alien - (%simple-eval original-exp lexenv)))) + (sb!alien-internals:alien-value exp)))) (list (let ((name (first exp)) (n-args (1- (length exp)))) diff --git a/src/code/full-eval.lisp b/src/code/full-eval.lisp index 718f5f1..08af268 100644 --- a/src/code/full-eval.lisp +++ b/src/code/full-eval.lisp @@ -522,9 +522,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 diff --git a/src/code/target-alieneval.lisp b/src/code/target-alieneval.lisp index a446c87..c66e364 100644 --- a/src/code/target-alieneval.lisp +++ b/src/code/target-alieneval.lisp @@ -70,6 +70,14 @@ (make-heap-alien-info :type type :sap-form `(foreign-symbol-sap ',alien-name t))))) +(defun alien-value (symbol) + #!+sb-doc + "Returns the value of the alien variable bound to SYMBOL. Signals an +error if SYMBOL is not bound to an alien variable, or if the alien +variable is undefined." + (%heap-alien (or (info :variable :alien-info symbol) + (error 'unbound-variable :name symbol)))) + (defmacro extern-alien (name type &environment env) #!+sb-doc "Access the alien variable named NAME, assuming it is of type TYPE. This -- 1.7.10.4