From 5f52a049c75fd0eeaa33656785891dea65b55a1f Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20V=C3=A1zquez?= Date: Thu, 2 May 2013 16:03:39 +0100 Subject: [PATCH] Character printing --- src/compiler.lisp | 5 ++++- src/print.lisp | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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"))) -- 1.7.10.4