summaryrefslogtreecommitdiff
path: root/module/language/ecmascript/impl.scm
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2009-02-20 16:15:50 +0100
committerAndy Wingo <wingo@pobox.com>2009-02-21 00:33:04 +0100
commita2879878187c348e07dfa8975a1b8f71afb50e57 (patch)
tree1fc8e96540304c45d015cdd3b6d74e7fe56db9c6 /module/language/ecmascript/impl.scm
parent785fb107ef1df793182f59f00251f9f7e3959792 (diff)
downloadguile-a2879878187c348e07dfa8975a1b8f71afb50e57.tar.gz
implement ++, --, new, delete, void, typeof
* module/language/ecmascript/compile-ghil.scm (@impl): Implement with @implv. (comp): Implement ++ and -- (pre- and post-). Quite a pain. I'll be looking for ways to simplify this notation. Also implement new, delete, and void. * module/language/ecmascript/impl.scm: Implement typeof.
Diffstat (limited to 'module/language/ecmascript/impl.scm')
-rw-r--r--module/language/ecmascript/impl.scm12
1 files changed, 11 insertions, 1 deletions
diff --git a/module/language/ecmascript/impl.scm b/module/language/ecmascript/impl.scm
index 2ab83a158..fd6ed8865 100644
--- a/module/language/ecmascript/impl.scm
+++ b/module/language/ecmascript/impl.scm
@@ -24,7 +24,7 @@
#:use-module (language ecmascript base)
#:use-module (language ecmascript function)
#:use-module (language ecmascript array)
- #:export (get-this)
+ #:export (get-this typeof)
#:re-export (*undefined* *this* call/this*
pget pput pdel
new-object
@@ -33,3 +33,13 @@
(define (get-this)
(fluid-ref *this*))
+
+(define (typeof x)
+ (cond ((eq? x *undefined*) "undefined")
+ ((null? x) "object")
+ ((boolean? x) "boolean")
+ ((number? x) "number")
+ ((string? x) "string")
+ ((procedure? x) "function")
+ ((is-a? x <js-object>) "object")
+ (else "scm")))