From: David Vázquez Date: Thu, 2 May 2013 15:03:39 +0000 (+0100) Subject: Character printing X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=5f52a049c75fd0eeaa33656785891dea65b55a1f;p=jscl.git Character printing --- diff --git a/src/compiler.lisp b/src/compiler.lisp index dec5eaa..eadbf39 100644 --- a/src/compiler.lisp +++ b/src/compiler.lisp @@ -1472,7 +1472,10 @@ "String.fromCharCode(x)")) (define-builtin characterp (x) - (js!bool (code "(typeof(" x ") == \"string\")"))) + (js!bool + (js!selfcall + "var x = " x ";" *newline* + "return (typeof(" x ") == \"string\") && x.length == 1;"))) (define-builtin char-to-string (x) (type-check (("x" "number" x)) diff --git a/src/print.lisp b/src/print.lisp index 919ab3d..dfa1b69 100644 --- a/src/print.lisp +++ b/src/print.lisp @@ -34,6 +34,12 @@ ":" name))))) ((integerp form) (integer-to-string form)) ((floatp form) (float-to-string form)) + ((characterp form) + (concat "#\\" + (case form + (#\newline "newline") + (#\space "space") + (otherwise (string form))))) ((stringp form) (concat "\"" (escape-string form) "\"")) ((functionp form) (let ((name (oget form "fname")))