From 1a2ec1b3444fe17bcd517fcf911ac33ac3e6f973 Mon Sep 17 00:00:00 2001 From: David Vazquez Date: Sat, 22 Dec 2012 01:50:13 +0000 Subject: [PATCH] Quoted symbols are also interned in the target environment --- lispstrack.lisp | 14 ++++++++------ test.lisp | 5 ++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lispstrack.lisp b/lispstrack.lisp index 7848b81..019635f 100644 --- a/lispstrack.lisp +++ b/lispstrack.lisp @@ -375,7 +375,7 @@ ((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: " @@ -383,11 +383,13 @@ (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)) diff --git a/test.lisp b/test.lisp index 489c36c..ec9ac8b 100644 --- a/test.lisp +++ b/test.lisp @@ -20,9 +20,6 @@ (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))))) @@ -30,6 +27,8 @@ (defun find-symbol (name) (get *package* name)) +(defvar t 't) +(defvar nil 'nil) (defmacro when (condition &rest body) `(if ,condition (progn ,@body) nil)) -- 1.7.10.4