mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-16 16:50:21 +02:00
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.
This commit is contained in:
parent
e80ce73d20
commit
785fb107ef
4 changed files with 27 additions and 4 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue