From: David Vazquez Date: Wed, 16 Jan 2013 01:47:54 +0000 (+0000) Subject: symbol-function checks if the function is defined X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=204c7064cb1d792fc7aaf3d7819244bc3fc052c3;p=jscl.git symbol-function checks if the function is defined --- diff --git a/ecmalisp.lisp b/ecmalisp.lisp index 77f337f..cd831bf 100644 --- a/ecmalisp.lisp +++ b/ecmalisp.lisp @@ -1309,7 +1309,11 @@ "return value;" *newline*)) (define-builtin symbol-function (x) - (concat "(" x ").function")) + (js!selfcall + "var symbol = " x ";" *newline* + "var func = symbol.function;" *newline* + "if (func === undefined) throw \"Function `\" + symbol.name + \"' is undefined.\";" *newline* + "return func;" *newline*)) (define-builtin eq (x y) (js!bool (concat "(" x " === " y ")"))) (define-builtin equal (x y) (js!bool (concat "(" x " == " y ")"))) @@ -1505,7 +1509,6 @@ *literal-symbols*) (setq *environment* ',*environment*) (setq *variable-counter* ,*variable-counter*) - (setq *function-counter* ,*function-counter*) (setq *gensym-counter* ,*gensym-counter*) (setq *block-counter* ,*block-counter*))))) @@ -1545,7 +1548,6 @@ (setq *literal-symbols* nil) (setq *variable-counter* 0 *gensym-counter* 0 - *function-counter* 0 *literal-counter* 0 *block-counter* 0) (ls-compile-file "ecmalisp.lisp" "ecmalisp.js")))