On Sep-26, Leopold Toetsch wrote:
> Dan Sugalski <[EMAIL PROTECTED]> wrote:
> 
> [ splatted function args ]
> 
> > ... For this, I think we're
> > going to need a "setp Ix, Py" op which does indirect register addressing.
> 
> Done.

Cool, thanks!

With it, I've been able to get a bit farther. Found a minor bug where
it multiply defines a label if you make two calls.

I'm not sure IMCC is going to be able to autogenerate the prototyped
and nonprototyped versions of the callee's entry code from the same
set of .param declarations.

 sub f3($a, $b, ?$c)

If that is converted to

 .param $a
 .param $b
 .param $c

then IMCC is going to get very unhappy when you call it without a
prototype and only pass it two arguments. If it is converted to

 .param $a
 .param $b
 .param remaining_args
 .local $c
 if remaining_args > 0
   $c = shift remaining_args

then I'll need to pass in the extra remaining_args array in all calls,
prototyped or non-. That's not a huge deal, and it fixes this problem.
But you'll hit it again if you call &f3 unprototyped with

 &f3(3, b => 4);

Named arguments cause a lot more trouble than that, but I still don't
want to go into that yet. But the above example should be enough to
demonstrate that one set of .param declarations won't be enough unless
we add more metadata to the declarations, and that feels like it might
be too perl6-specific.

How bad would it be to do:

 .pcc_sub _main
 .pcc_non_prototyped
   # .
   # .
   # .
   # code to place params into the registers that they would
   # be in if called with a prototype. I'm not sure if IMCC
   # can autogenerate any of this or not.
   # .
   # .
   # .
   # IMCC inserts a jump to the main body of the routine
 .pcc_prototyped
   .param _SV_a
   .param _SV_b
   .param _SV_c # This is a little strange. The caller knows the prototype,
                # so can pass in an undef if the 3rd argument wasn't given.
                # But the callee may have a different default value in
                # mind than undef, and if it's an expression then it
                # probably needs to be evaluated by the callee in its
                # local environment. We could create a new UnpassedArg PMC,
                # or we could add something to the calling conventions
                # so that you know how many arguments were actually
                # passed.
 .pcc_body
   # subroutine body
 .end

The non-prototyped section would want to use the same _SV_? variables,
so perhaps the prototyped section should come first.

Reply via email to