(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."
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))))
(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
;;; 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))
(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)