mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-15 00:37:35 +02:00
Detect actual recursive calls
This commit is contained in:
parent
8930d9c8df
commit
fb8de77d37
1 changed files with 17 additions and 5 deletions
|
@ -919,13 +919,25 @@
|
|||
(set-c-call-arity! (c:num-args cargs))
|
||||
(let* ((wkf (well-known-lambda (car args)))
|
||||
(fnc (if wkf (adb:get/default (ast:lambda-id wkf) #f) #f))
|
||||
(ast-fnc (adb:get/default ast-id #f))
|
||||
)
|
||||
(cond
|
||||
;; TODO: check for self-call
|
||||
;; TODO: use (self-closure-call? ast self)
|
||||
;; ((and fnc
|
||||
;; (adbf:calls-self? fnc)
|
||||
;;
|
||||
;; Handle recursive calls via iteration, if possible
|
||||
((and ast-fnc
|
||||
(adbf:calls-self? ast-fnc)
|
||||
(self-closure-call? fun (car (adbf:all-params ast-fnc)))
|
||||
)
|
||||
(c-code
|
||||
(string-append
|
||||
(c:allocs->str (c:allocs cfun) "\n")
|
||||
(c:allocs->str (c:allocs cargs) "\n")
|
||||
"/* TODO: call self */ return_closcall" (number->string (c:num-args cargs))
|
||||
"(data,"
|
||||
this-cont
|
||||
(if (> (c:num-args cargs) 0) "," "")
|
||||
(c:body cargs)
|
||||
");")))
|
||||
|
||||
((and wkf fnc
|
||||
*optimize-well-known-lambdas*
|
||||
(adbf:well-known fnc) ;; not really needed
|
||||
|
|
Loading…
Add table
Reference in a new issue