From 48a4a97dcf473d3b90b10cbf536f0dc1705b1024 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20V=C3=A1zquez?= Date: Sun, 23 Jun 2013 21:30:21 +0200 Subject: [PATCH] Migrate SYMBOL-FUNCTION and SYMBOL-VALUE --- src/compiler.lisp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) 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) ")")) -- 1.7.10.4