Fix GET-INTERNAL-REAL-TIME
[jscl.git] / src / compiler.lisp
index 047f42d..d299902 100644 (file)
 
 (defun gvarname (symbol)
   (declare (ignore symbol))
-  (code "v" (incf *variable-counter*)))
+  (incf *variable-counter*)
+  (concat "v" (integer-to-string *variable-counter*)))
 
 (defun translate-variable (symbol)
   (awhen (lookup-in-lexenv symbol *environment* 'variable)
         (when name      `(= (get func |fname|) ,name))
         (when docstring `(= (get func |docstring|) ,docstring))
         `(return func))
-      `(code ,code)))
+      code))
 
 (defun lambda-check-argument-count
     (n-required-arguments n-optional-arguments rest-p)
 (defvar *literal-counter* 0)
 
 (defun genlit ()
-  (code "l" (incf *literal-counter*)))
+  (incf *literal-counter*)
+  (concat "l" (integer-to-string *literal-counter*)))
 
 (defun dump-symbol (symbol)
   #-jscl
     `(return r)))
 
 (define-builtin get-internal-real-time ()
-  `(call (get (new (call Date)) "getTime")))
+  `(call (get (new (call |Date|)) "getTime")))
 
 (define-builtin values-array (array)
   (if *multiple-value-p*
   (js!bool `(in (call |xstring| ,key) ,object)))
 
 (define-builtin map-for-in (function object)
-  (js!selfcall
-   "var f = " function ";"
-   "var g = (typeof f === 'function' ? f : f.fvalue);"
-   "var o = " object ";"
-   "for (var key in o){"
-   `(code "g(" ,(if *multiple-value-p* "values" "pv") ", 1, o[key]);" )
-   "}"
-   " return " (ls-compile nil) ";" ))
+  (js!selfcall*
+    `(var (f ,function)
+          (g (if (=== (typeof f) "function") f (get f "fvalue")))
+          (o ,object))
+    `(for-in (key o)
+       (call g ,(if *multiple-value-p* '|values| '|pv|) 1 (get o "key")))
+    `(return ,(ls-compile nil))))
 
 (define-compilation %js-vref (var)
   `(code "js_to_lisp(" ,var ")"))