From 302205da72ffd846f51753f761a34f9e5af23f0b Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20V=C3=A1zquez?= Date: Mon, 24 Jun 2013 13:57:35 +0200 Subject: [PATCH] Migrate OGET* --- src/compiler.lisp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/compiler.lisp b/src/compiler.lisp index a77d451..a65cd33 100644 --- a/src/compiler.lisp +++ b/src/compiler.lisp @@ -1305,14 +1305,15 @@ '(object)) (define-raw-builtin oget* (object key &rest keys) - (js!selfcall - "var tmp = (" (ls-compile object) ")[xstring(" (ls-compile key) ")];" - `(code - ,@(mapcar (lambda (key) - `(code "if (tmp === undefined) return " ,(ls-compile nil) ";" - "tmp = tmp[xstring(" ,(ls-compile key) ")];" )) - keys)) - "return tmp === undefined? " (ls-compile nil) " : tmp;" )) + (js!selfcall* + `(progn + (var (tmp (get ,(ls-compile object) (call |xstring| ,(ls-compile key))))) + ,@(mapcar (lambda (key) + `(progn + (if (=== tmp undefined) (return ,(ls-compile nil))) + (= tmp (get tmp (call |xstring| ,(ls-compile key)))))) + keys)) + `(return (if (=== tmp undefined) ,(ls-compile nil) tmp)))) (define-raw-builtin oset* (value object key &rest keys) (let ((keys (cons key keys))) -- 1.7.10.4