[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 15/16: Unknown primcalls convert as calls

From: Andy Wingo
Subject: [Guile-commits] 15/16: Unknown primcalls convert as calls
Date: Wed, 27 Dec 2017 10:02:49 -0500 (EST)

wingo pushed a commit to branch master
in repository guile.

commit bc5a599cadb23829f751c4d25ca4da11528ab934
Author: Andy Wingo <address@hidden>
Date:   Wed Dec 27 11:04:26 2017 +0100

    Unknown primcalls convert as calls
    * module/language/cps/reify-primitives.scm (reify-primitives): Remove
      case where $prim could continue to $kreceive; this isn't possible.
      However when reifying an unknown primcall, always add a $kreceive, as
      the continuation has to be $kargs.
    * module/language/tree-il/compile-cps.scm (convert): Unknown primcalls
      convert as calls.  With this change, all primcalls should continue to
      $kargs, with the exception of 'throw.
 module/language/cps/reify-primitives.scm | 5 ++---
 module/language/tree-il/compile-cps.scm  | 9 +++++----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/module/language/cps/reify-primitives.scm 
index 52c7573..8765ee2 100644
--- a/module/language/cps/reify-primitives.scm
+++ b/module/language/cps/reify-primitives.scm
@@ -237,7 +237,6 @@
          (setk label ($kfun src meta self tail clause))))
       (($ $kargs names vars ($ $continue k src ($ $prim name)))
        (with-cps cps
-         (let$ k (uniquify-receive k))
          (let$ body (resolve-prim name k src))
          (setk label ($kargs names vars ,body))))
       (($ $kargs names vars
@@ -380,9 +379,9 @@
          (with-cps cps
            (letv proc)
-           (let$ k (uniquify-receive k))
+           (letk krecv ($kreceive '(res) #f k))
            (letk kproc ($kargs ('proc) (proc)
-                               ($continue k src ($call proc args))))
+                         ($continue krecv src ($call proc args))))
            (let$ body (resolve-prim name kproc src))
            (setk label ($kargs names vars ,body))))))
       (($ $kargs names vars
diff --git a/module/language/tree-il/compile-cps.scm 
index e690a40..e66b09b 100644
--- a/module/language/tree-il/compile-cps.scm
+++ b/module/language/tree-il/compile-cps.scm
@@ -820,13 +820,14 @@
                    (build-term ($continue kprim src ($prim name))))))))))
        ;; We have something that's a primcall for Tree-IL but not for
-       ;; CPS, which will get compiled as a call and so the right thing
-       ;; to do is to continue to the given $ktail or $kreceive.
+       ;; CPS; compile as a call.
        (convert-args cps args
          (lambda (cps args)
            (with-cps cps
-             (build-term
-               ($continue k src ($primcall name #f args)))))))))
+             (letv prim)
+             (letk kprim ($kargs ('prim) (prim)
+                           ($continue k src ($call prim args))))
+             (build-term ($continue kprim src ($prim name)))))))))
     ;; Prompts with inline handlers.
     (($ <prompt> src escape-only? tag body

reply via email to

[Prev in Thread] Current Thread [Next in Thread]