X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=ecmalisp.lisp;h=57f793b32b404895865df91e17c90f713df122d7;hb=c277546f4ba4aaeee4bc3b25facef9e42582011b;hp=77f337ff859833afff1468b368094abf6918a113;hpb=adaa2ca564b08d889f1909d4012284b39a056475;p=jscl.git diff --git a/ecmalisp.lisp b/ecmalisp.lisp index 77f337f..57f793b 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 ")"))) @@ -1416,19 +1420,10 @@ form))) (defun compile-funcall (function args env) - (cond - ((symbolp function) - (concat (ls-compile `(quote ,function)) ".function(" - (join (mapcar (lambda (x) (ls-compile x env)) args) - ", ") - ")")) - ((and (listp function) (eq (car function) 'lambda)) - (concat "(" (ls-compile function env) ")(" - (join (mapcar (lambda (x) (ls-compile x env)) args) - ", ") - ")")) - (t - (error (concat "Invalid function designator " (symbol-name function)))))) + (concat (ls-compile `#',function) "(" + (join (mapcar (lambda (x) (ls-compile x env)) args) + ", ") + ")")) (defun ls-compile (sexp &optional (env (make-lexenv))) (cond @@ -1505,7 +1500,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 +1539,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")))