# New Ticket Created by  Bob Rogers 
# Please include the string:  [perl #38348]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=38348 >


   It seems that Continuation needs the same set_address magic as
Exception_Handler in order to return values.  Which means that
Exception_Handler can just inherit the magic.  Having this extra magic
doesn't seem to bother RetContinuation, though I'm not sure that I
understand why it doesn't, but at least RetContinuation is thoroughly
covered by the test suite, so I think it's probably OK.

   Unless there's supposed to be another way to return values when
calling a Continuation?

                                        -- Bob Rogers
                                           http://rgrjr.dyndns.org/

Index: src/pmc/continuation.pmc
===================================================================
--- src/pmc/continuation.pmc    (revision 11359)
+++ src/pmc/continuation.pmc    (working copy)
@@ -150,22 +150,30 @@
 
 =item C<void set_pointer(void *value)>
 
-Sets the pointer to the actual subroutine.
+Sets the pointer to the return instruction.
 
 =cut
 
 */
 
     void set_pointer (void* value) {
+        opcode_t *pos = value;
+        struct Parrot_cont * cc = PMC_cont(SELF);
+
         PObj_get_FLAGS(SELF) |= PObj_private1_FLAG;
-        PMC_cont(SELF)->address = value;
+        cc->address = value;
+        if (pos && *pos == PARROT_OP_get_results_pc) {
+            cc->current_results = pos;
+        }
+        else
+            cc->current_results = NULL;
     }
 
 /*
 
 =item C<void *get_pointer()>
 
-Returns the pointer to the actual subroutine.
+Returns the pointer to the return instruction.
 
 =cut
 
Index: src/pmc/exception_handler.pmc
===================================================================
--- src/pmc/exception_handler.pmc       (revision 11359)
+++ src/pmc/exception_handler.pmc       (working copy)
@@ -82,17 +82,6 @@
         return result;
     }
 
-    void set_pointer (void* value) {
-        opcode_t *pos = value;
-        struct Parrot_cont * cc = PMC_cont(SELF);
-        if (*pos == PARROT_OP_get_results_pc) {
-            cc->current_results = pos;
-        }
-        else
-            cc->current_results = NULL;
-        SUPER(value);
-    }
-
     void* invoke (void* ex) {
         struct Parrot_cont * cc = PMC_cont(SELF);
         PMC *exception = ex;
Index: t/op/calling.t
===================================================================
--- t/op/calling.t      (revision 11359)
+++ t/op/calling.t      (working copy)
@@ -1579,6 +1579,31 @@
 ok 2
 OUTPUT
 
+pir_output_is(<<'CODE', <<'OUTPUT', "set_args via explicit continuation");
+.sub main :main
+    .local string result
+    result = "not ok 2\n"
+    .local pmc cont
+    cont = new .Continuation
+    set_addr cont, cont_dest
+    bar(cont, "ok 1\n")
+    print "oops\n"
+cont_dest:
+    .get_results (result)
+    print result
+.end
+
+.sub bar
+    .param pmc cc
+    .param string s
+    print s
+    cc("ok 2\n")
+.end
+CODE
+ok 1
+ok 2
+OUTPUT
+
 pir_output_is(<<'CODE', <<'OUTPUT', "call evaled vtable code");
 .sub main :main
     .local string s
@@ -2154,5 +2179,5 @@
 /duplicate name/
 OUTPUT
 ## remember to change the number of tests :-)
-BEGIN { plan tests => 85 }
+BEGIN { plan tests => 86 }
 

Reply via email to