((null sexp) "false")
((integerp sexp) (integer-to-string sexp))
((stringp sexp) (concat "\"" (escape-string sexp) "\""))
- ((symbolp sexp) (concat "{name: \"" (escape-string (symbol-name sexp)) "\"}"))
+ ((symbolp sexp) (ls-compile `(intern ,(escape-string (symbol-name sexp))) *env* *fenv*))
((consp sexp) (concat "{car: "
(literal->js (car sexp))
", cdr: "
(let ((counter 0))
(defun literal (form)
- (if (null form)
- (literal->js form)
- (let ((var (concat "l" (integer-to-string (incf counter)))))
- (push (concat "var " var " = " (literal->js form)) *toplevel-compilations*)
- var))))
+ (cond
+ ((null form)
+ (literal->js form))
+ (t
+ (let ((var (concat "l" (integer-to-string (incf counter)))))
+ (push (concat "var " var " = " (literal->js form)) *toplevel-compilations*)
+ var)))))
(define-compilation quote (sexp)
(literal sexp))
(defvar *package* (new))
-(defvar t 't)
-(defvar nil 'nil)
-
(defun intern (name)
(let ((s (get *package* name)))
(if s s (set *package* name (make-symbol name)))))
(defun find-symbol (name)
(get *package* name))
+(defvar t 't)
+(defvar nil 'nil)
(defmacro when (condition &rest body)
`(if ,condition (progn ,@body) nil))