From 7be0b81d5015288b5788bc069802aa1a37edf792 Mon Sep 17 00:00:00 2001 From: Olof-Joachim Frahm Date: Wed, 16 Oct 2013 00:01:43 +0200 Subject: [PATCH] Fix variables for FFI, convert T/NIL, true/false/null. --- src/boot.lisp | 1 + src/compiler/compiler.lisp | 2 +- src/prelude.js | 13 +++++++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/boot.lisp b/src/boot.lisp index 736c07d..f181239 100644 --- a/src/boot.lisp +++ b/src/boot.lisp @@ -50,6 +50,7 @@ ',name)) (defconstant t 't) +(%js-vset "t" t) (defconstant nil 'nil) (%js-vset "nil" nil) diff --git a/src/compiler/compiler.lisp b/src/compiler/compiler.lisp index 7ce004d..ffa0c7d 100644 --- a/src/compiler/compiler.lisp +++ b/src/compiler/compiler.lisp @@ -1362,7 +1362,7 @@ `(property ,obj (call |xstring| ,p))) (mapcar #'convert (cdr function))) ,@(mapcar (lambda (s) - `(call |lisp_to_js| ,s)) + `(call |lisp_to_js| ,(convert s))) args)))) (t (error "Bad function descriptor"))))) diff --git a/src/prelude.js b/src/prelude.js index 9214436..f3ef952 100644 --- a/src/prelude.js +++ b/src/prelude.js @@ -2,6 +2,7 @@ // contain runtime code that jscl assumes to exist. var window = this; +var t; var nil; var lisp = {}; @@ -114,7 +115,11 @@ function Symbol(name, package_name){ } function lisp_to_js (x) { - if (typeof x == 'object' && 'length' in x && x.stringp == 1) + if (x === nil) + return null; + else if (x === t) + return true; + else if (typeof x == 'object' && 'length' in x && x.stringp == 1) return xstring(x); else if (typeof x == 'function'){ // Trampoline calling the Lisp function @@ -129,7 +134,11 @@ function lisp_to_js (x) { } function js_to_lisp (x) { - if (typeof x == 'string') + if (x === null || x === undefined || x === false) + return nil; + else if (x === true) + return t; + else if (typeof x == 'string') return make_lisp_string(x); else if (typeof x == 'function'){ // Trampoline calling the JS function -- 1.7.10.4