X-Git-Url: https://git.hcoop.net/clinton/parenscript.git/blobdiff_plain/d7fe9ef286c622d33c1f43dbae72694efad6a711..5ffb1ebaaff5e8f899fd4b1bd91b015f2c52d656:/src/compiler.lisp diff --git a/src/compiler.lisp b/src/compiler.lisp index 2281ab3..0cc8dc7 100644 --- a/src/compiler.lisp +++ b/src/compiler.lisp @@ -52,6 +52,9 @@ lexical block.") (defvar *ps-special-variables* ()) +(defun ps-special-variable-p (sym) + (member sym *ps-special-variables*)) + ;;; form predicates (defun op-form-p (form) @@ -273,7 +276,10 @@ the form cannot be compiled to a symbol." (defvar *ps-gensym-counter* 0) (defun ps-gensym (&optional (prefix "_js")) - (make-symbol (format nil "~A~A" prefix (incf *ps-gensym-counter*)))) + (let ((prefix (if (stringp prefix) prefix (symbol-to-js-string prefix nil)))) + (make-symbol (format nil "~A~:[~;_~]~A" prefix + (digit-char-p (char prefix (1- (length prefix)))) + (incf *ps-gensym-counter*))))) (defmacro with-ps-gensyms (symbols &body body) "Evaluate BODY with SYMBOLS bound to unique ParenScript identifiers.