Expand compound symbol (warning: very lightly tested)
authorClinton Ebadi <clinton@unknownlamer.org>
Tue, 6 Oct 2009 18:52:41 +0000 (14:52 -0400)
committerClinton Ebadi <clinton@unknownlamer.org>
Tue, 6 Oct 2009 18:52:41 +0000 (14:52 -0400)
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

index 4e16ba8..a55fe46 100644 (file)
@@ -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)))
                (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
 
 
 ;;; operators
 
@@ -291,10 +293,15 @@ the form cannot be compiled to a symbol."
                     ',(make-symbol (subseq (symbol-name (first form)) 1)))
      ,@(cddr form))))
 
                     ',(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))
 (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))))
 
          (ps-compile-expression (ps-macroexpand (car form))))
     ,@(mapcar #'ps-compile-expression (cdr form))))