From: Clinton Ebadi Date: Tue, 6 Oct 2009 18:52:41 +0000 (-0400) Subject: Expand compound symbol (warning: very lightly tested) X-Git-Url: https://git.hcoop.net/clinton/parenscript.git/commitdiff_plain/c2c51a3db0b1bff4be5cf2afc8166f8220edfade Expand compound symbol (warning: very lightly tested) Performs expansion and renaming of compound symbols in `ps-compile-symbol' and for function names in `(funcall NAME . args)' forms. This will probably break with other special forms and needs more testing / possible reimplementation at another level of the compiler. --- diff --git a/src/compiler.lisp b/src/compiler.lisp index 4e16ba8..a55fe46 100644 --- a/src/compiler.lisp +++ b/src/compiler.lisp @@ -225,7 +225,9 @@ the form cannot be compiled to a symbol." (if (ps-reserved-symbol-p symbol) (funcall (get-ps-special-form symbol)) (error "Attempting to use Parenscript special form ~a as variable" symbol))) - (t `(js:variable ,symbol)))))) + (t (aif (compound-symbol-p symbol) + it + `(js:variable ,symbol))))))) ;;; operators @@ -291,10 +293,15 @@ the form cannot be compiled to a symbol." ',(make-symbol (subseq (symbol-name (first form)) 1))) ,@(cddr form)))) +(defun function-name->js-expression (name) + (aif (compound-symbol-p name) + it + `(js:variable ,(maybe-rename-local-function name)))) + (defun compile-funcall-form (form) `(js:funcall ,(if (symbolp (car form)) - `(js:variable ,(maybe-rename-local-function (car form))) + (function-name->js-expression (car form)) (ps-compile-expression (ps-macroexpand (car form)))) ,@(mapcar #'ps-compile-expression (cdr form))))