[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 14/99: Add binop type
From: |
Christopher Allan Webber |
Subject: |
[Guile-commits] 14/99: Add binop type |
Date: |
Sun, 10 Oct 2021 21:50:44 -0400 (EDT) |
cwebber pushed a commit to branch compile-to-js-merge
in repository guile.
commit 30afdcd97678e7aceb9bea187752f307a936f5ca
Author: Ian Price <ianprice90@googlemail.com>
AuthorDate: Mon Jun 8 18:02:01 2015 +0100
Add binop type
---
module/language/javascript.scm | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/module/language/javascript.scm b/module/language/javascript.scm
index 37b7b28..7486213 100644
--- a/module/language/javascript.scm
+++ b/module/language/javascript.scm
@@ -14,6 +14,7 @@
make-refine refine
make-branch branch
make-var var
+ make-binop binop
print-statement))
@@ -57,6 +58,7 @@
(define-js-type refine id field)
(define-js-type branch test then else)
(define-js-type var id exp)
+(define-js-type binop op arg1 arg2)
(define (unparse-js exp)
(match exp
@@ -81,7 +83,9 @@
(block ,@(map unparse-js then))
(block ,@(map unparse-js else))))
(($ var id exp)
- `(var ,id ,(unparse-js exp)))))
+ `(var ,id ,(unparse-js exp)))
+ (($ binop op arg1 arg2)
+ `(binop ,op ,arg1 ,arg2))))
(define (print-exp exp port)
(match exp
@@ -123,7 +127,25 @@
(($ new expr)
(format port "new ")
- (print-exp expr port))))
+ (print-exp expr port))
+
+ (($ binop op arg1 arg2)
+ (display "(" port)
+ (print-exp arg1 port)
+ (display ")" port)
+ (print-binop op port)
+ (display "(" port)
+ (print-exp arg2 port)
+ (display ")" port))))
+
+(define (print-binop op port)
+ (case op
+ ((or) (display "||" port))
+ ((and) (display "&&" port))
+ ((=) (display "==" port))
+ ((+ - < <= > >=) (format port "~a" op))
+ (else
+ (throw 'unprintable-binop op))))
(define (print-statement stmt port)
(match stmt
- [Guile-commits] 98/99: Merge branch 'main' into compile-to-js-merge, (continued)
- [Guile-commits] 98/99: Merge branch 'main' into compile-to-js-merge, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 78/99: Implement Hook Builtins, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 81/99: Argument to make-fluid is optional, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 83/99: Implement variable-bound? builtin, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 88/99: read argument to --depends switch, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 89/99: extra-dependencies go before boot-dependencies, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 90/99: Mention all arguments to guild jslink in --help, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 92/99: Merge branch 'compile-to-js-2017' into compile-to-js-rebase, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 99/99: Compile cps to bytecode by default, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 24/99: Primitives create multiple argument continuations., Christopher Allan Webber, 2021/10/10
- [Guile-commits] 14/99: Add binop type,
Christopher Allan Webber <=
- [Guile-commits] 53/99: Implement Winding & Unwinding, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 63/99: Implement hashtable built-ins, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 66/99: Implement misc built-ins, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 61/99: define! primitive only takes one argument., Christopher Allan Webber, 2021/10/10
- [Guile-commits] 69/99: Unwind prompt frames, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 67/99: Make child structs applicable., Christopher Allan Webber, 2021/10/10
- [Guile-commits] 74/99: Reimplement JS module system primitives., Christopher Allan Webber, 2021/10/10
- [Guile-commits] 95/99: Fix import of lower-cps in compile-js.scm, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 73/99: Implement unboxed integer primitives., Christopher Allan Webber, 2021/10/10
- [Guile-commits] 76/99: Separate public / private module lookups, Christopher Allan Webber, 2021/10/10