Root higher-order CPS term is always $kfun $cont
[bpt/guile.git] / module / language / cps / closure-conversion.scm
index 151448e..08e511d 100644 (file)
@@ -272,13 +272,11 @@ convert functions to flat closures."
     (($ $cont sym ($ $kfun src meta self tail clause))
      (sym ($kfun src meta self ,tail ,(and clause (visit-cont clause)))))))
 
-(define (convert-closures exp)
+(define (convert-closures fun)
   "Convert free reference in @var{exp} to primcalls to @code{free-ref},
 and allocate and initialize flat closures."
-  (match exp
-    (($ $fun () body)
-     (with-fresh-name-state body
-       (receive (body free) (cc body #f '())
-         (unless (null? free)
-           (error "Expected no free vars in toplevel thunk" exp body free))
-         (convert-to-indices body free))))))
+  (with-fresh-name-state fun
+    (receive (body free) (cc fun #f '())
+      (unless (null? free)
+        (error "Expected no free vars in toplevel thunk" fun body free))
+      (convert-to-indices body free))))