Refactored ps-compiler method name for symbols.
authorVladimir Sedach <vsedach@gmail.com>
Fri, 11 Sep 2009 09:37:03 +0000 (03:37 -0600)
committerVladimir Sedach <vsedach@gmail.com>
Fri, 11 Sep 2009 09:37:03 +0000 (03:37 -0600)
src/compiler.lisp
src/special-forms.lisp

index 4daf9e9..42c68f8 100644 (file)
@@ -184,12 +184,10 @@ form, FORM, returns the new value for *ps-compilation-level*."
 
 
 (defmethod compile-parenscript-form :around (form &key expecting)
-  (assert (if expecting (member expecting '(:expression :statement :symbol)) t))
-  (if (eq expecting :symbol)
-      (compile-to-symbol form)
-      (call-next-method)))
+  (assert (if expecting (member expecting '(:expression :statement)) t))
+  (call-next-method))
 
-(defun compile-to-symbol (form)
+(defun ps-compile-symbol (form)
   "Compiles the given Parenscript form and guarantees that the
 resultant symbol has an associated script-package. Raises an error if
 the form cannot be compiled to a symbol."
@@ -278,7 +276,7 @@ the form cannot be compiled to a symbol."
       form))
 
 (defun compile-op-form (form)
-  `(js:operator ,(ps-convert-op-name (compile-parenscript-form (car form) :expecting :symbol))
+  `(js:operator ,(ps-convert-op-name (ps-compile-symbol (car form)))
                 ,@(mapcar (lambda (form)
                             (compile-parenscript-form (ps-macroexpand form) :expecting :expression))
                           (cdr form))))
index a8e6def..4144eca 100644 (file)
 (defvar *vars-bound-in-enclosing-lexical-scopes* ())
 
 (defun compile-function-definition (args body)
-  (let ((args (mapcar (lambda (arg) (compile-parenscript-form arg :expecting :symbol)) args)))
+  (let ((args (mapcar #'ps-compile-symbol args)))
     (list args
           (let* ((*enclosing-lexical-block-declarations* ())
                  (*vars-bound-in-enclosing-lexical-scopes* (append args
@@ -653,7 +653,7 @@ lambda-list::=
 ;;; iteration
 (defun make-for-vars/inits (init-forms)
   (mapcar (lambda (x)
-            (cons (compile-parenscript-form (ps-macroexpand (if (atom x) x (first x))) :expecting :symbol)
+            (cons (ps-compile-symbol (ps-macroexpand (if (atom x) x (first x))))
                   (compile-parenscript-form (ps-macroexpand (if (atom x) nil (second x))) :expecting :expression)))
           init-forms))
 
@@ -758,8 +758,8 @@ lambda-list::=
     (assert (or catch finally) ()
             "Try form should have either a catch or a finally clause or both.")
     `(js:try ,(compile-parenscript-form `(progn ,form))
-          :catch ,(when catch (list (compile-parenscript-form (caar catch) :expecting :symbol)
-                                   (compile-parenscript-form `(progn ,@(cdr catch)))))
+          :catch ,(when catch (list (ps-compile-symbol (caar catch))
+                                    (compile-parenscript-form `(progn ,@(cdr catch)))))
           :finally ,(when finally (compile-parenscript-form `(progn ,@finally))))))
 
 (define-ps-special-form cc-if (test &rest body)