From: David Vázquez Date: Sun, 23 Jun 2013 19:15:10 +0000 (+0200) Subject: Migrate CAR and CDR X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=1da7705a5f46c895d61264476beba363d7f98cac;p=jscl.git Migrate CAR and CDR --- 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))