Ticket #199 (closed todo: fixed)

Opened 6 years ago

Last modified 5 years ago

fix handling of vtable methods

Reported by: whiteknight Owned by: whiteknight
Priority: normal Milestone: 0.9.1
Component: imcc Version:
Severity: medium Keywords:
Cc: Language:
Patch status: Platform: all

Description

In object.pmc, all vtable overrides are invoked with Parrot_call_meth_fromc_args. This function passes SELF as an invocant to all vtable overrides in PIR. This means that any vtable interfaces that aren't also flagged as being methods (either explicitly with :method or implicitly by referencing self) will throw an exception because there are too many parameters passed (the normal parameters + 1 for the invocant).

We should update vtable overrides in PIR to always be treated as if they have :method as well. I can't imagine a use case where we actually don't want a reference to the invocant to be passed. I think this should be relatively easy to hack into IMCC, unless somebody comes up with a disagreement.

Change History

Changed 6 years ago by whiteknight

Okay, here's the scoop:

1) I found how to fix this issue. The relevant code is in compilers/imcc/pcc.c:390. We need to add the condition " (unit->is_vtable_method)" to that if statement, and this resolves the problem. 2) However, the problem above breaks t/pmc/parrotobject.t, tests involving "invoke". The "invoke" override is broken internally and does not allow for a "self" parameter. When IMCC tries to unshift a "self" off the list of arguments, it comes up one argument short.

We have a few tests for overriding "invoke", but none of them test the desired behavior (having access to "self" and therefore being able to do anything interesting besides printing out simple messages). However, when I fix behavior elsewhere these examples rightfully break.

Changed 5 years ago by kjs

I think this ticket is a duplicate of #103. I'm not sure, but if so, this ticket can be rejected/marked as duplicate.

Regarding the problem that is indicated: it is expected that the indicated test, in t/pmc/parrotobject.t breaks, because the test is wrong!

If you want to invoke a vtable method without using *method* invocation syntax, you'll need to pass the object itself explicitly.

Changed 5 years ago by whiteknight

  • status changed from new to closed
  • resolution set to fixed

I think this ticket is similar not not exactly the same as #103. I do think that this has been resolved by an earlier patch/commit, so I'm marking it as resolved. All :vtables now have access to "self" except for the special case of "invoke", which is the subject of #103.

Note: See TracTickets for help on using tickets.