From 1da7705a5f46c895d61264476beba363d7f98cac Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20V=C3=A1zquez?= Date: Sun, 23 Jun 2013 21:15:10 +0200 Subject: [PATCH] Migrate CAR and CDR --- src/compiler.lisp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/compiler.lisp b/src/compiler.lisp index 88fafe2..28462ba 100644 --- a/src/compiler.lisp +++ b/src/compiler.lisp @@ -1095,18 +1095,18 @@ "return (typeof tmp == 'object' && 'car' in tmp);" ))) (define-builtin car (x) - (js!selfcall - "var tmp = " x ";" - "return tmp === " (ls-compile nil) - "? " (ls-compile nil) - ": tmp.car;" )) + (js!selfcall* + `(var (tmp ,x)) + `(return (if (=== tmp ,(ls-compile nil)) + ,(ls-compile nil) + (get tmp "car"))))) (define-builtin cdr (x) - (js!selfcall - "var tmp = " x ";" - "return tmp === " (ls-compile nil) "? " - (ls-compile nil) - ": tmp.cdr;" )) + (js!selfcall* + `(var (tmp ,x)) + `(return (if (=== tmp ,(ls-compile nil)) + ,(ls-compile nil) + (get tmp "cdr"))))) (define-builtin rplaca (x new) (type-check (("x" "object" x)) -- 1.7.10.4