Below is a rather straightforward patch, but as it represents an interface change (albeit a fully backwards compatible one), I thought I would post it for discussion.

Background on the proposed change: there apparently are two sets of "runops" functions, I'd characterize Parrot_runops_fromc as a "do it yourself" function in which you are responsible for all registers, and a set of "convenience" functions which take care of marshalling arguments.

At the moment, there is one important way in which the convenience functions are more functional: set_retval has access to the register set which were active when the Sub was invoked.

This patch brings Parrot_runops_fromc to parity by providing access to those registers.

- Sam Ruby
Index: include/parrot/interpreter.h
===================================================================
RCS file: /cvs/public/parrot/include/parrot/interpreter.h,v
retrieving revision 1.164
diff -u -r1.164 interpreter.h
--- include/parrot/interpreter.h        24 Nov 2004 05:56:55 -0000      1.164
+++ include/parrot/interpreter.h        15 Dec 2004 03:12:20 -0000
@@ -400,7 +400,7 @@
 
 void runops(Interp *, size_t offset);
 void runops_int(Interp *, size_t offset);
-void Parrot_runops_fromc(Interp *, PMC *sub);
+struct parrot_regs_t* Parrot_runops_fromc(Interp *, PMC *sub);
 void* Parrot_runops_fromc_args(Interp *, PMC *sub, const char *sig, ...);
 INTVAL Parrot_runops_fromc_args_reti(Interp *, PMC *, const char *, ...);
 FLOATVAL Parrot_runops_fromc_args_retf(Interp *, PMC *, const char *, ...);
Index: src/inter_run.c
===================================================================
RCS file: /cvs/public/parrot/src/inter_run.c,v
retrieving revision 1.24
diff -u -r1.24 inter_run.c
--- src/inter_run.c     13 Dec 2004 21:51:00 -0000      1.24
+++ src/inter_run.c     15 Dec 2004 03:12:20 -0000
@@ -102,7 +102,7 @@
 
 /*
 
-=item C<void
+=item C<struct parrot_regs_t *
 Parrot_runops_fromc(Parrot_Interp interpreter, PMC *sub)>
 
 Runs the Parrot ops, called from C code. The function arguments are
@@ -113,11 +113,12 @@
 
 */
 
-void
+struct parrot_regs_t *
 Parrot_runops_fromc(Parrot_Interp interpreter, PMC *sub)
 {
     PMC *ret_c, *p1;
     opcode_t offset, *dest;
+    struct parrot_regs_t *bp;
 
     /* we need one return continuation with a NULL offset */
     p1 = REG_PMC(1);
@@ -130,11 +131,13 @@
      * Passing a dummy true destination copies registers
      */
     dest = VTABLE_invoke(interpreter, sub, (void*) 1);
+    bp = interpreter->ctx.bp;
     if (dest) {
         offset = dest - interpreter->code->byte_code;
         runops(interpreter, offset);
     }
     REG_PMC(1) = p1;
+    return bp;
 }
 
 /*

Reply via email to