mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-09 14:07:34 +02:00
Find inlinable scheme functions
This commit is contained in:
parent
b607f9a420
commit
f1d5bb6f83
2 changed files with 8 additions and 10 deletions
12
cyclone.scm
12
cyclone.scm
|
@ -225,12 +225,12 @@
|
|||
(trace:info "---------------- after func->primitive conversion:")
|
||||
(trace:info input-program) ;pretty-print
|
||||
|
||||
;(trace:info "---------------- results of inlinable-top-level-function analysis: ")
|
||||
;(for-each
|
||||
; (lambda (e)
|
||||
; (if (inlinable-top-level-function? e)
|
||||
; (trace:info (define->var e))))
|
||||
; input-program)
|
||||
(trace:info "---------------- results of inlinable-top-level-function analysis: ")
|
||||
(for-each
|
||||
(lambda (e)
|
||||
(if (inlinable-top-level-function? e)
|
||||
(trace:info (define->var e))))
|
||||
input-program)
|
||||
|
||||
(let ((cps (map
|
||||
(lambda (expr)
|
||||
|
|
|
@ -1234,6 +1234,7 @@
|
|||
;; Determine if the given top-level function can be freed from CPS, due
|
||||
;; to it only containing calls to code that itself can be inlined.
|
||||
(define (inlinable-top-level-function? expr)
|
||||
(define this-fnc-sym (define->var expr))
|
||||
(define (scan expr fail)
|
||||
(cond
|
||||
((string? expr) (fail))
|
||||
|
@ -1246,11 +1247,9 @@
|
|||
(scan (if->else expr) fail))
|
||||
((app? expr)
|
||||
(let ((fnc (car expr)))
|
||||
;(inline-fnc (prim:func->prim (car expr) (- (length expr) 1))))
|
||||
;; If function needs CPS, fail right away
|
||||
(if (or (not (prim? fnc)) ;; Eventually need to handle user functions, too
|
||||
(prim:cont? fnc) ;; Needs CPS
|
||||
;(equal? fnc inline-fnc) ;; No inline version
|
||||
)
|
||||
(fail))
|
||||
;; Otherwise, check for valid args
|
||||
|
@ -1266,8 +1265,7 @@
|
|||
;; NOTE: would not be able to detect all functions in this module immediately.
|
||||
;; would probably have to find some, then run this function successively to find others.
|
||||
;;
|
||||
;; define, set - reject
|
||||
;; lambda of all forms - reject
|
||||
;; Reject everything else - define, set, lambda
|
||||
(else (fail))))
|
||||
(cond
|
||||
((and (define? expr)
|
||||
|
|
Loading…
Add table
Reference in a new issue