summaryrefslogtreecommitdiff
path: root/module/language/ecmascript/compile-ghil.scm
diff options
context:
space:
mode:
Diffstat (limited to 'module/language/ecmascript/compile-ghil.scm')
-rw-r--r--module/language/ecmascript/compile-ghil.scm77
1 files changed, 76 insertions, 1 deletions
diff --git a/module/language/ecmascript/compile-ghil.scm b/module/language/ecmascript/compile-ghil.scm
index 18746995e..5834771cd 100644
--- a/module/language/ecmascript/compile-ghil.scm
+++ b/module/language/ecmascript/compile-ghil.scm
@@ -73,6 +73,14 @@
(make-ghil-quote e l str))
(this
(@impl e l get-this '()))
+ ((+ ,a)
+ (make-ghil-inline e l 'add (list (comp a e) (make-ghil-quote e l 0))))
+ ((- ,a)
+ (make-ghil-inline e l 'sub (list (make-ghil-quote e l 0) (comp a e))))
+ ((~ ,a)
+ (@impl e l bitwise-not (list (comp a e))))
+ ((! ,a)
+ (@impl e l logical-not (list (comp a e))))
((+ ,a ,b)
(make-ghil-inline e l 'add (list (comp a e) (comp b e))))
((- ,a ,b)
@@ -81,6 +89,48 @@
(make-ghil-inline e l 'div (list (comp a e) (comp b e))))
((* ,a ,b)
(make-ghil-inline e l 'mul (list (comp a e) (comp b e))))
+ ((% ,a ,b)
+ (@impl e l mod (list (comp a e) (comp b e))))
+ ((<< ,a ,b)
+ (@impl e l shift (list (comp a e) (comp b e))))
+ ((>> ,a ,b)
+ (@impl e l shift (list (comp a e) (comp `(- ,b) e))))
+ ((< ,a ,b)
+ (make-ghil-inline e l 'lt? (list (comp a e) (comp b e))))
+ ((<= ,a ,b)
+ (make-ghil-inline e l 'le? (list (comp a e) (comp b e))))
+ ((> ,a ,b)
+ (make-ghil-inline e l 'gt? (list (comp a e) (comp b e))))
+ ((>= ,a ,b)
+ (make-ghil-inline e l 'ge? (list (comp a e) (comp b e))))
+ ((in ,a ,b)
+ (@impl e l has-property? (list (comp a e) (comp b e))))
+ ((== ,a ,b)
+ (make-ghil-inline e l 'equal? (list (comp a e) (comp b e))))
+ ((!= ,a ,b)
+ (make-ghil-inline e l 'not
+ (list
+ (make-ghil-inline e l 'equal?
+ (list (comp a e) (comp b e))))))
+ ((=== ,a ,b)
+ (make-ghil-inline e l 'eqv? (list (comp a e) (comp b e))))
+ ((!== ,a ,b)
+ (make-ghil-inline e l 'not
+ (list
+ (make-ghil-inline e l 'eqv?
+ (list (comp a e) (comp b e))))))
+ ((& ,a ,b)
+ (@impl e l band (list (comp a e) (comp b e))))
+ ((^ ,a ,b)
+ (@impl e l bxor (list (comp a e) (comp b e))))
+ ((bor ,a ,b)
+ (@impl e l bior (list (comp a e) (comp b e))))
+ ((and ,a ,b)
+ (make-ghil-and e l (list (comp a e) (comp b e))))
+ ((or ,a ,b)
+ (make-ghil-or e l (list (comp a e) (comp b e))))
+ ((if ,test ,then ,else)
+ (make-ghil-if e l (comp test e) (comp then e) (comp else e)))
((postinc (ref ,foo))
(begin1 (comp `(ref ,foo) e)
(lambda (var)
@@ -273,11 +323,36 @@
((aref ,obj ,index)
(@impl e l pget (list (comp obj e) (comp index e))))
((= (ref ,name) ,val)
- (make-ghil-set e l (ghil-var-for-set! e name) (comp val e)))
+ (let ((v (ghil-var-for-set! e name)))
+ (make-ghil-begin e l
+ (list (make-ghil-set e l v (comp val e))
+ (make-ghil-ref e l v)))))
((= (pref ,obj ,prop) ,val)
(@impl e l pput (list (comp obj e) (make-ghil-quote e l prop) (comp val e))))
((= (aref ,obj ,prop) ,val)
(@impl e l pput (list (comp obj e) (comp prop e) (comp val e))))
+ ((+= ,what ,val)
+ (comp `(= ,what (+ ,what ,val)) e))
+ ((-= ,what ,val)
+ (comp `(= ,what (- ,what ,val)) e))
+ ((/= ,what ,val)
+ (comp `(= ,what (/ ,what ,val)) e))
+ ((*= ,what ,val)
+ (comp `(= ,what (* ,what ,val)) e))
+ ((%= ,what ,val)
+ (comp `(= ,what (% ,what ,val)) e))
+ ((>>= ,what ,val)
+ (comp `(= ,what (>> ,what ,val)) e))
+ ((<<= ,what ,val)
+ (comp `(= ,what (<< ,what ,val)) e))
+ ((>>>= ,what ,val)
+ (comp `(= ,what (>>> ,what ,val)) e))
+ ((&= ,what ,val)
+ (comp `(= ,what (& ,what ,val)) e))
+ ((bor= ,what ,val)
+ (comp `(= ,what (bor ,what ,val)) e))
+ ((^= ,what ,val)
+ (comp `(= ,what (^ ,what ,val)) e))
((new ,what ,args)
(@impl e l new (map (lambda (x) (comp x e)) (cons what args))))
((delete (pref ,obj ,prop))