summaryrefslogtreecommitdiff
path: root/module/language/ecmascript/compile-ghil.scm
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2009-02-20 13:21:09 +0100
committerAndy Wingo <wingo@pobox.com>2009-02-21 00:33:03 +0100
commit785fb107ef1df793182f59f00251f9f7e3959792 (patch)
treecbbe442822233e93b0989c91f081afb7254c65ba /module/language/ecmascript/compile-ghil.scm
parente80ce73d209892bae3bea80853d9e0e16cd82ed1 (diff)
downloadguile-785fb107ef1df793182f59f00251f9f7e3959792.tar.gz
handle "this" in ecmascript
* module/language/ecmascript/base.scm: * module/language/ecmascript/compile-ghil.scm: * module/language/ecmascript/impl.scm: * module/language/ecmascript/parse.scm: Compile "method calls" in such a way that "this" gets propagated correctly.
Diffstat (limited to 'module/language/ecmascript/compile-ghil.scm')
-rw-r--r--module/language/ecmascript/compile-ghil.scm16
1 files changed, 16 insertions, 0 deletions
diff --git a/module/language/ecmascript/compile-ghil.scm b/module/language/ecmascript/compile-ghil.scm
index 825599d05..2f385643f 100644
--- a/module/language/ecmascript/compile-ghil.scm
+++ b/module/language/ecmascript/compile-ghil.scm
@@ -62,6 +62,8 @@
(make-ghil-quote e l num))
((string ,str)
(make-ghil-quote e l str))
+ (this
+ (@impl e l get-this '()))
((+ ,a ,b)
(make-ghil-inline e l 'add (list (comp a e) (comp b e))))
((- ,a ,b)
@@ -95,6 +97,20 @@
(lambda (env vars)
(make-ghil-lambda env l vars #t '()
(comp-body env l body formals '%args)))))
+ ((call/this ,obj ,prop ,args)
+ (@impl e l call/this*
+ (list obj (make-ghil-lambda
+ e l '() #f '()
+ (make-ghil-call e l (@impl e l pget (list obj prop))
+ args)))))
+ ((call (pref ,obj ,prop) ,args)
+ (comp `(call/this ,(comp obj e) ,(make-ghil-quote e l prop)
+ ,(map (lambda (x) (comp x e)) args))
+ e))
+ ((call (aref ,obj ,prop) ,args)
+ (comp `(call/this ,(comp obj e) ,(comp prop e)
+ ,(map (lambda (x) (comp x e)) args))
+ e))
((call ,proc ,args)
(make-ghil-call e l (comp proc e) (map (lambda (x) (comp x e)) args)))
((return ,expr)