mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-17 17:20:29 +02:00
conditional->branch
This commit is contained in:
parent
3b32d180b1
commit
f8618a522f
2 changed files with 8 additions and 8 deletions
|
@ -12,7 +12,7 @@
|
||||||
make-new new
|
make-new new
|
||||||
make-id id
|
make-id id
|
||||||
make-refine refine
|
make-refine refine
|
||||||
make-conditional conditional
|
make-branch branch
|
||||||
make-var var
|
make-var var
|
||||||
|
|
||||||
print-statement))
|
print-statement))
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
(define-js-type new expr)
|
(define-js-type new expr)
|
||||||
(define-js-type id name)
|
(define-js-type id name)
|
||||||
(define-js-type refine id field)
|
(define-js-type refine id field)
|
||||||
(define-js-type conditional test then else)
|
(define-js-type branch test then else)
|
||||||
(define-js-type var id exp)
|
(define-js-type var id exp)
|
||||||
|
|
||||||
(define (unparse-js exp)
|
(define (unparse-js exp)
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
`(id ,name))
|
`(id ,name))
|
||||||
(($ refine id field)
|
(($ refine id field)
|
||||||
`(refine ,(unparse-js id) ,(unparse-js field)))
|
`(refine ,(unparse-js id) ,(unparse-js field)))
|
||||||
(($ conditional test then else)
|
(($ branch test then else)
|
||||||
`(if ,(unparse-js test)
|
`(if ,(unparse-js test)
|
||||||
(block ,@(map unparse-js then))
|
(block ,@(map unparse-js then))
|
||||||
(block ,@(map unparse-js else))))
|
(block ,@(map unparse-js else))))
|
||||||
|
@ -134,7 +134,7 @@
|
||||||
(print-exp exp port)
|
(print-exp exp port)
|
||||||
(format port ";"))
|
(format port ";"))
|
||||||
|
|
||||||
(($ conditional test then else)
|
(($ branch test then else)
|
||||||
(format port "if (")
|
(format port "if (")
|
||||||
(print-exp test port)
|
(print-exp test port)
|
||||||
(format port ") {")
|
(format port ") {")
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
(make-return (make-call (name->id k) (map compile-exp exps))))
|
(make-return (make-call (name->id k) (map compile-exp exps))))
|
||||||
|
|
||||||
(($ il:branch test then else)
|
(($ il:branch test then else)
|
||||||
(make-conditional (make-call (make-refine *scheme* (make-const "is_true"))
|
(make-branch (make-call (make-refine *scheme* (make-const "is_true"))
|
||||||
(list (compile-exp test)))
|
(list (compile-exp test)))
|
||||||
(list (compile-exp then))
|
(list (compile-exp then))
|
||||||
(list (compile-exp else))))
|
(list (compile-exp else))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue