1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-17 17:20:29 +02:00

Get rid of comments and dead branches

This commit is contained in:
Ian Price 2015-06-06 20:15:25 +01:00
parent 54ce470cf8
commit d1a663baec
4 changed files with 7 additions and 29 deletions

View file

@ -16,7 +16,6 @@
;; first-order optimization should go here ;; first-order optimization should go here
(set! exp (reify-primitives exp)) (set! exp (reify-primitives exp))
(set! exp (renumber exp)) (set! exp (renumber exp))
;; (values exp env env)
(match exp (match exp
(($ $program funs) (($ $program funs)
;; TODO: I should special case the compilation for the initial fun, ;; TODO: I should special case the compilation for the initial fun,
@ -27,16 +26,12 @@
(values (make-program (compile-fun (car funs)) (values (make-program (compile-fun (car funs))
(map compile-fun (cdr funs))) (map compile-fun (cdr funs)))
env env
env))) env))))
)
(define (compile-fun fun) (define (compile-fun fun)
;; meta
(match fun (match fun
(($ $cont k ($ $kfun src meta self ($ $cont tail ($ $ktail)) clause)) (($ $cont k ($ $kfun src meta self ($ $cont tail ($ $ktail)) clause))
(make-var k (compile-clause clause self tail))) (make-var k (compile-clause clause self tail)))))
(_
`(fun:todo: ,fun))))
(define (compile-clause clause self tail) (define (compile-clause clause self tail)
(match clause (match clause
@ -58,9 +53,7 @@
(compile-term exp)) (compile-term exp))
(($ $cont k _) (($ $cont k _)
(make-local (list (compile-cont body)) (make-local (list (compile-cont body))
(make-continue k (map make-id req))))))) (make-continue k (map make-id req)))))))))
(_
`(clause:todo: ,clause))))
(define (not-supported msg clause) (define (not-supported msg clause)
(error 'not-supported msg clause)) (error 'not-supported msg clause))
@ -115,9 +108,7 @@
;; FIXME: ;; FIXME:
;; may happen if a test branch of a conditional compiles to values ;; may happen if a test branch of a conditional compiles to values
;; placeholder till I learn if multiple values could be returned. ;; placeholder till I learn if multiple values could be returned.
(make-id val)) (make-id val))))
(_
`(exp:todo: ,exp))))
(define (compile-test exp kt kf) (define (compile-test exp kt kf)
;; TODO: find out if the expression is always simple enough that I ;; TODO: find out if the expression is always simple enough that I

View file

@ -182,9 +182,3 @@
(display separator port) (display separator port)
(printer x port)) (printer x port))
rest)))) rest))))
(define (print-terminated args printer terminator port)
(for-each (lambda (x)
(printer x port)
(display terminator port))
args))

View file

@ -7,13 +7,12 @@
make-continuation continuation make-continuation continuation
make-local local make-local local
make-var var make-var var
make-continue continue ; differ from conts make-continue continue
make-const const make-const const
make-primcall primcall make-primcall primcall
make-call call make-call call
make-closure closure make-closure closure
make-branch branch make-branch branch
; print-js
make-return return make-return return
make-id id make-id id
)) ))
@ -78,7 +77,6 @@
`(continue ,k ,(map unparse-js args))) `(continue ,k ,(map unparse-js args)))
(($ branch test then else) (($ branch test then else)
`(if ,(unparse-js test) ,(unparse-js then) ,(unparse-js else))) `(if ,(unparse-js test) ,(unparse-js then) ,(unparse-js else)))
;; values
(($ const c) (($ const c)
`(const ,c)) `(const ,c))
(($ primcall name args) (($ primcall name args)
@ -90,8 +88,4 @@
(($ return val) (($ return val)
`(return . ,(unparse-js val))) `(return . ,(unparse-js val)))
(($ id name) (($ id name)
`(id . ,name)) `(id . ,name))))
(_
;(error "unexpected js" exp)
(pk 'unexpected exp)
exp)))

View file

@ -1,6 +1,5 @@
(define-module (language js-il spec) (define-module (language js-il spec)
#:use-module (system base language) #:use-module (system base language)
; #:use-module (language js-il)
#:use-module (language js-il compile-javascript) #:use-module (language js-il compile-javascript)
#:export (js-il)) #:export (js-il))
@ -8,5 +7,5 @@
#:title "Javascript Intermediate Language" #:title "Javascript Intermediate Language"
#:reader #f #:reader #f
#:compilers `((javascript . ,compile-javascript)) #:compilers `((javascript . ,compile-javascript))
#:printer #f ; print-js #:printer #f
#:for-humans? #f) #:for-humans? #f)