mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-15 08:47: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))
|
(set-c-call-arity! (c:num-args cargs))
|
||||||
(let* ((wkf (well-known-lambda (car args)))
|
(let* ((wkf (well-known-lambda (car args)))
|
||||||
(fnc (if wkf (adb:get/default (ast:lambda-id wkf) #f) #f))
|
(fnc (if wkf (adb:get/default (ast:lambda-id wkf) #f) #f))
|
||||||
|
(ast-fnc (adb:get/default ast-id #f))
|
||||||
)
|
)
|
||||||
(cond
|
(cond
|
||||||
;; TODO: check for self-call
|
;; Handle recursive calls via iteration, if possible
|
||||||
;; TODO: use (self-closure-call? ast self)
|
((and ast-fnc
|
||||||
;; ((and fnc
|
(adbf:calls-self? ast-fnc)
|
||||||
;; (adbf:calls-self? 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
|
((and wkf fnc
|
||||||
*optimize-well-known-lambdas*
|
*optimize-well-known-lambdas*
|
||||||
(adbf:well-known fnc) ;; not really needed
|
(adbf:well-known fnc) ;; not really needed
|
||||||
|
|
Loading…
Add table
Reference in a new issue