"Leopold Toetsch" <[EMAIL PROTECTED]> wrote:
On Oct 24, 2005, at 0:07, Jonathan Worthington wrote:

"Leopold Toetsch" <[EMAIL PROTECTED]> wrote:

op result_count(out INT)        # TODO or some such

I'm guessing TODO means "it's not done yet"? But I was wondering, would a more general solution not be to have an op that hands back the results PMC constant that specifies the types as well as number of return values, then you can just call the elements vtable function for that PMC to get the number of arguments, plus other info is available too, and we just have the one new op?

Yep. That's the more general solution:

op result_info(out PMC) {
  PMC *i;
  if (PMC_IS_NULL(i = CONTEXT(interpreter->ctx)->current_results))
$1 = pmc_new(interpreter, enum_class_FixedIntegerArray); /* 0 elems aka void */
  else
    $1 = i;
  goto NEXT();
 }

# untested ;-)

And something of an over-simplification, as it turned out.  ;-)

Either way, I should have time to look at putting an op to do something like this in soon, if leo or @other don't beat me to it. ;-)

Drop something like above into experimental.ops and let's see, how it works.

Done, plus some tests in calling.t. Sorry it took a while - it's been a crappy week for me. :-(

Roger: It works like this:-

$P0 = result_info
$I0 = elements $P0

Will leave $I0 containing the number of return values. Have fun, any problems just shout.

Thanks,

Jonathan

Reply via email to