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:
parent
d1a663baec
commit
3b32d180b1
2 changed files with 38 additions and 0 deletions
|
@ -2,9 +2,11 @@
|
|||
#:use-module (ice-9 match)
|
||||
#:use-module ((language js-il) #:renamer (symbol-prefix-proc 'il:))
|
||||
#:use-module (language javascript)
|
||||
#:use-module (language js-il direct)
|
||||
#:export (compile-javascript))
|
||||
|
||||
(define (compile-javascript exp env opts)
|
||||
(set! exp (remove-immediate-calls exp))
|
||||
(values (compile-exp exp) env env))
|
||||
|
||||
(define *scheme* (make-id "scheme"))
|
||||
|
|
36
module/language/js-il/direct.scm
Normal file
36
module/language/js-il/direct.scm
Normal 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)))
|
Loading…
Add table
Add a link
Reference in a new issue