From 34dd089e729a3980a23f26f1f601fd58069f6e27 Mon Sep 17 00:00:00 2001 From: David Vazquez Date: Sun, 16 Dec 2012 03:30:06 +0000 Subject: [PATCH] Conses are working --- lispstrack.lisp | 8 ++++---- prelude.js | 14 -------------- test.lisp | 9 +++++++++ 3 files changed, 13 insertions(+), 18 deletions(-) delete mode 100644 prelude.js diff --git a/lispstrack.lisp b/lispstrack.lisp index 9add3b3..d3771fe 100644 --- a/lispstrack.lisp +++ b/lispstrack.lisp @@ -175,13 +175,13 @@ (concat "((" (ls-compile x env fenv) ") == (" (ls-compile y env fenv) "))")) (define-compilation cons (x y) - (concat "(new Cons("y", " x "))")) + (concat "{car: " (ls-compile x env fenv) ", cdr: " (ls-compile y env fenv) "}")) (define-compilation car (x) - (concat "(x.car)")) + (concat "(" (ls-compile x env fenv) ").car")) (define-compilation cdr (x) - (concat "(x.cdr)")) + (concat "(" (ls-compile x env fenv) ").cdr")) (defmacro with-eval-when-compilation (&body body) `(setq *eval-when-compilations* @@ -241,7 +241,7 @@ (with-open-file (out output :direction :output :if-exists :supersede) (loop for x = (read in nil) while x - for compilation = (ls-compile x) + for compilation = (ls-compile-toplevel x) when compilation do (write-line (concat compilation "; ") out))))) diff --git a/prelude.js b/prelude.js deleted file mode 100644 index 3b566b1..0000000 --- a/prelude.js +++ /dev/null @@ -1,14 +0,0 @@ -// - -function Symbol(name){ - this.name = name; -} - -function Cons(car, cdr){ - this.car = car; - this.cdr = cdr; -} - - - -console.log('Running test.js...'); diff --git a/test.lisp b/test.lisp index 210ef66..4b87743 100644 --- a/test.lisp +++ b/test.lisp @@ -33,6 +33,9 @@ (defmacro incf (x) (list 'setq x (list '+ 1 x))) +(eval-when-compile + (%compile-defvar 'x)) + (setq x 10) (incf x) (debug x) @@ -44,6 +47,12 @@ (debug (lambda (x y &rest z) z)) (debug (lambda (x y &rest z) x)) +;;; Conses +(debug (cons 1 2)) +(debug (car (cons 1 2))) +(debug (cdr (cons 1 2))) + + ;; (eval-when-compile ;; (%compile-defmacro 'defun ;; (lambda (name args &rest body) -- 1.7.10.4