From: David Vázquez Date: Sun, 23 Jun 2013 19:30:21 +0000 (+0200) Subject: Migrate SYMBOL-FUNCTION and SYMBOL-VALUE X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=48a4a97dcf473d3b90b10cbf536f0dc1705b1024;p=jscl.git Migrate SYMBOL-FUNCTION and SYMBOL-VALUE --- diff --git a/src/compiler.lisp b/src/compiler.lisp index 92c847f..c118761 100644 --- a/src/compiler.lisp +++ b/src/compiler.lisp @@ -1138,18 +1138,20 @@ (js!bool `(!== (get ,x "fvalue") undefined))) (define-builtin symbol-value (x) - (js!selfcall - "var symbol = " x ";" - "var value = symbol.value;" - "if (value === undefined) throw \"Variable `\" + xstring(symbol.name) + \"' is unbound.\";" - "return value;" )) + (js!selfcall* + `(var (symbol ,x) + (value (get symbol "value"))) + `(if (=== value undefined) + (throw (+ "Variable `" (call |xstring| (get symbol "name")) "' is unbound."))) + `(return value))) (define-builtin symbol-function (x) - (js!selfcall - "var symbol = " x ";" - "var func = symbol.fvalue;" - "if (func === undefined) throw \"Function `\" + xstring(symbol.name) + \"' is undefined.\";" - "return func;" )) + (js!selfcall* + `(var (symbol ,x) + (func (get symbol "fvalue"))) + `(if (=== func undefined) + (throw (+ "Function `" (call |xstring| (get symbol "name")) "' is undefined."))) + `(return func))) (define-builtin symbol-plist (x) `(code "((" ,x ").plist || " ,(ls-compile nil) ")"))