From 23aaae8f051acec5e8a960233662b3c6b9180ee3 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Fri, 19 Oct 2018 13:23:18 -0400 Subject: [PATCH] WIP --- scheme/cyclone/cgen.sld | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/scheme/cyclone/cgen.sld b/scheme/cyclone/cgen.sld index 3aa70014..57d74096 100644 --- a/scheme/cyclone/cgen.sld +++ b/scheme/cyclone/cgen.sld @@ -839,7 +839,7 @@ "\n" cgen-body ;; TODO: (c:body cgen) ;; TODO: re-assign function args, longer-term using temp variables "\n" - "goto loop;"))) + "continue;"))) ) ((prim? fun) @@ -1484,10 +1484,15 @@ (> (string-length tmp-ident) 3) (equal? "self" (substring tmp-ident 0 4)))) (has-loop? - (and (not has-closure?) ;; Only top-level functions for now - (pair? trace) - (not (null? (cdr trace))) - (adbv:direct-rec-call? (adb:get (cdr trace))))) + (or + (adbf:calls-self? (adb:get/default (ast:lambda-id exp) (adb:make-fnc))) + ;; Older direct recursive logic + (and (not has-closure?) ;; Only top-level functions for now + (pair? trace) + (not (null? (cdr trace))) + (adbv:direct-rec-call? (adb:get (cdr trace)))) + ) + ) (formals* (string-append (if has-closure? @@ -1536,8 +1541,8 @@ (else (string-append (st:->code trace) - ;; TODO: probably needs brackets afterwards... - (if has-loop? "\nloop: {\n" "") + TODO: does not work for calls-self, need to invoke that elsewhere... + (if has-loop? "\n while(1) {\n" "") )))) body) " ")