From c2c51a3db0b1bff4be5cf2afc8166f8220edfade Mon Sep 17 00:00:00 2001 From: Clinton Ebadi Date: Tue, 6 Oct 2009 14:52:41 -0400 Subject: [PATCH] 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. --- src/compiler.lisp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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)))) -- 2.20.1