(incf index))
output)))
-#+common-lisp
+#-jscl
(defun indent (&rest string)
(with-output-to-string (*standard-output*)
(with-input-from-string (input (apply #'code string))
;;; evaluated. For this reason we define a valid macro-function for
;;; this symbol.
(defvar *magic-unquote-marker* (gensym "MAGIC-UNQUOTE"))
-#+common-lisp
+#-jscl
(setf (macro-function *magic-unquote-marker*)
(lambda (form &optional environment)
(declare (ignore environment))
(code "l" (incf *literal-counter*)))
(defun dump-symbol (symbol)
- #+common-lisp
+ #-jscl
(let ((package (symbol-package symbol)))
(if (eq package (find-package "KEYWORD"))
(code "(new Symbol(" (dump-string (symbol-name symbol)) ", " (dump-string (package-name package)) "))")
"if (i < 0 || i >= x.length) throw 'Out of range';" *newline*
"return x[i] = " value ";" *newline*))
+(define-builtin afind (value array)
+ (js!selfcall
+ "var v = " value ";" *newline*
+ "var x = " array ";" *newline*
+ "return x.indexOf(v);" *newline*))
+
+(define-builtin aresize (array new-size)
+ (js!selfcall
+ "var x = " array ";" *newline*
+ "var n = " new-size ";" *newline*
+ "return x.length = n;" *newline*))
+
(define-builtin get-internal-real-time ()
"(new Date()).getTime()")
`(%js-vref ,var))))
-#+common-lisp
+#-jscl
(defvar *macroexpander-cache*
(make-hash-table :test #'eq))
(if (and b (eq (binding-type b) 'macro))
(let ((expander (binding-value b)))
(cond
- #+common-lisp
+ #-jscl
((gethash b *macroexpander-cache*)
(setq expander (gethash b *macroexpander-cache*)))
((listp expander)
;; function with the compiled one.
;;
#+jscl (setf (binding-value b) compiled)
- #+common-lisp (setf (gethash b *macroexpander-cache*) compiled)
+ #-jscl (setf (gethash b *macroexpander-cache*) compiled)
(setq expander compiled))))
expander)
nil)))
(concat (translate-function function) arglist))
((and (symbolp function)
#+jscl (eq (symbol-package function) (find-package "COMMON-LISP"))
- #+common-lisp t)
+ #-jscl t)
(code (ls-compile `',function) ".fvalue" arglist))
(t
(code (ls-compile `#',function) arglist)))))