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

Change function type representation

This commit is contained in:
Ian Price 2015-06-21 00:45:09 +01:00
parent a7b2dfa581
commit e9f37e6a31
4 changed files with 68 additions and 82 deletions

View file

@ -140,12 +140,14 @@
(($ il:continuation params body)
(make-function (map rename-id params) (list (compile-exp body))))
(($ il:function self tail body)
(($ il:function self tail clauses)
(make-function (list (rename-id self) (rename-id tail))
(list (compile-exp body))))
(($ il:jump-table specs)
(compile-jump-table specs))
(append
(map (match-lambda
((id _ body)
(make-var (rename-id id) (compile-exp body))))
clauses)
(list (compile-jump-table clauses)))))
(($ il:local bindings body)
(make-block (append (map compile-exp bindings) (list (compile-exp body)))))
@ -278,9 +280,11 @@
(map compile-id names)))))))
))
(fold-right (lambda (a d)
(make-branch (compile-test (car a))
(compile-jump (car a) (cdr a))
(list d)))
(match a
((id params _)
(make-branch (compile-test params)
(compile-jump params id)
(list d)))))
;; FIXME: should throw an error
(make-return (make-id "undefined"))
specs))

View file

@ -23,12 +23,9 @@
(($ program ((ids . funs) ...))
(for-each analyse funs))
(($ function self tail body)
(analyse body))
(($ jump-table spec)
(for-each (lambda (p) (analyse (cdr p)))
spec))
(($ function self tail ((($ kid ids) _ bodies) ...))
(for-each count-inc! ids) ;; count-inf! ?
(for-each analyse bodies))
(($ continuation params body)
(analyse body))
@ -184,18 +181,15 @@
(exp exp)))
(define (handle-function fun)
(define (handle-bindings bindings)
(map (lambda (binding)
(match binding
(($ var id ($ continuation params body))
(make-var id (make-continuation params (inline body '()))))))
bindings))
(match fun
(($ function self tail ($ local bindings ($ jump-table spec)))
(($ function self tail ((ids params bodies) ...))
(make-function self
tail
(make-local (handle-bindings bindings)
(make-jump-table spec))))))
(map (lambda (id param body)
(list id param (inline body '())))
ids
params
bodies)))))
(match exp
(($ program ((ids . funs) ...))