(not (ps-special-form-p form))
(not (null (op-precedence (first form))))))
+(defun method-call-form-p (form)
+ (and (listp form)
+ (symbolp (car form))
+ (char= #\. (char (symbol-name (car form)) 0))))
+
(defun funcall-form-p (form)
(and form
(listp form)
(ps-compile (string form)))
(defmethod ps-compile ((symbol symbol))
- (when (eq *ps-compilation-level* :toplevel)
- (multiple-value-bind (expansion expanded-p)
- (ps-macroexpand symbol)
- (when expanded-p
- (return-from ps-compile (ps-compile expansion)))))
- (cond ((keywordp symbol) symbol)
- ((ps-special-form-p (list 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))))
+ (multiple-value-bind (expansion expanded?)
+ (ps-macroexpand symbol)
+ (if expanded?
+ (ps-compile expansion)
+ (cond ((keywordp symbol) symbol)
+ ((ps-special-form-p (list 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))))))
;;; operators
(ps-compile-expression (ps-macroexpand form)))
(cdr form))))
+(defun compile-method-call-form (form)
+ (compile-funcall-form
+ `((js:slot-value ,(second form)
+ ',(make-symbol (subseq (symbol-name (first form)) 1)))
+ ,@(cddr form))))
+
(defun compile-funcall-form (form)
`(js:funcall
- ,(ps-compile-expression (if (symbolp (car form))
- (maybe-rename-local-function (car form))
- (ps-macroexpand (car form))))
+ ,(if (symbolp (car form))
+ `(js:variable ,(maybe-rename-local-function (car form)))
+ (ps-compile-expression (ps-macroexpand (car form))))
,@(mapcar #'ps-compile-expression (cdr form))))
(defvar compile-expression?)
(compile-op-form form))))
((op-form-p form)
(compile-op-form form))
+ ((method-call-form-p form)
+ (compile-method-call-form form))
((funcall-form-p form)
(compile-funcall-form form))
- (t (error "Cannot compile ~S to a ParenScript form." form))))))
+ (t (error "Cannot compile ~S to a ParenScript form." form))))))
(defun ps-compile-statement (form)
(let ((compile-expression? nil))