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

Simple inlining of immediate calls

This commit is contained in:
Ian Price 2015-06-07 16:58:41 +01:00
parent d1a663baec
commit 3b32d180b1
2 changed files with 38 additions and 0 deletions

View file

@ -2,9 +2,11 @@
#:use-module (ice-9 match) #:use-module (ice-9 match)
#:use-module ((language js-il) #:renamer (symbol-prefix-proc 'il:)) #:use-module ((language js-il) #:renamer (symbol-prefix-proc 'il:))
#:use-module (language javascript) #:use-module (language javascript)
#:use-module (language js-il direct)
#:export (compile-javascript)) #:export (compile-javascript))
(define (compile-javascript exp env opts) (define (compile-javascript exp env opts)
(set! exp (remove-immediate-calls exp))
(values (compile-exp exp) env env)) (values (compile-exp exp) env env))
(define *scheme* (make-id "scheme")) (define *scheme* (make-id "scheme"))

View file

@ -0,0 +1,36 @@
(define-module (language js-il direct)
#:use-module (ice-9 match)
#:use-module (language js-il)
#:export (remove-immediate-calls))
(define (remove-immediate-calls exp)
(match exp
(($ program entry body)
(make-program (remove-immediate-calls entry)
(map remove-immediate-calls body)))
(($ continuation params body)
(make-continuation params (remove-immediate-calls body)))
(($ function name params body)
(make-function name params (remove-immediate-calls body)))
(($ local
(($ var id ($ continuation () body)))
($ continue id ()))
(remove-immediate-calls body))
(($ local
(($ var id ($ continuation (arg) body)))
($ continue id (val)))
(make-local (list (make-var arg val))
(remove-immediate-calls body)))
(($ local bindings body)
(make-local (map remove-immediate-calls bindings)
(remove-immediate-calls body)))
(($ var id exp)
(make-var id (remove-immediate-calls exp)))
(exp exp)))