At 02:00 PM 12/12/2003 -0700, Cory Spencer wrote:

Can anyone tell me why the following code:

  .sub _main
        .local PerlUndef val

        val = new PerlUndef
        _foo("bar", val)

        end
  .end

  .sub _foo
        .param string v1
        .param pmc v2

        .pcc_begin_return
        .return 1
        .pcc_end_return
  .end

Would produce the following output:

  cog:~/parrot test.imc
  wrong param count
          in file '(unknown file)' near line -1

It seems to be related to passing the PerlUndef as the seoncd
parameter...

When using prototyped subs and mixing native types with PMC types as arguments, IMCC will get confused. Its because it isn't correctly checking the prototypes. The other problem is that when you use the shorthand version of sub calling (_foo(a,b)), IMCC assumes prototyped.

It stems mainly from 2a below.

I recommend: (1) Using non_prototyped subs and explicit .pcc_call directives,
rather than the shorthand version for now.

Until I get some fixes committed you have a couple of other options:

(2) Don't mix PMCs and native types in argument lists if you use prototyped subs
(2a) If you use PMCs, then IMCC won't coerce a constant argument into a
PMC yet. _foo("bar", val) will pass "bar" as a plain string type, even if the prototype
expects a PMC. This is a bug.


I expect to have a large revision soon that will address lots of issues in IMCC, but
it will most likely be in a new branch (imcc2) so as not to cause complete chaos with
the "semi-stable" version. Then I will try to backpatch some of those fixes into the
current IMCC.


-Melvin




Reply via email to