Leopold Toetsch writes: > Luke Palmer <[EMAIL PROTECTED]> wrote: > > How does one call a parrot Sub from C and get the return value(s)? Is > > it even possible, given CPS, to do this generally? If not, how can I > > check when it is? > > Good question. Its very similar to classes/Eval.pmc:invoke(). > You would do: > - call runops_int(interp, offset)
Okay, now I've got a pretty nice XS interface for embedding and introspecting into a parrot interp from Perl. I just figured out what you meant by "offset", but the way I compute it is, well: void _run_sub (interp, pmc) Parrot_Interp interp PMC* pmc INIT: PMC* retc = pmc_new_noinit(interp, enum_class_RetContinuation); CODE: VTABLE_init(interp, retc); VTABLE_set_integer_native(interp, retc, 0); interp->pmc_reg.registers[0] = pmc; interp->pmc_reg.registers[1] = retc; runops_int(interp, ((void*)VTABLE_invoke(interp, pmc, NULL) - (void*)interp->code->byte_code)>>2); Is there a better way to do it (other than stylistic concerns)? Oh, don't worry about parameter passing, I've that handled in the Perl front end. Also, I can't seem to figure out how to make a CSub which calls to a user-provided perl sub. It seems I need more metadata, specifically, the SV containing the sub. Should I just subclass CSub and include it in pmc_val or somesuch? Or does CSub already do what I need? Thanks again, Luke > - returning from the sub is by invoke'ing the return continuation with > address 0, which you have put in P1 > - param passing is like PCC (pdd03) > > > Thanks, > > Luke > > leo