Skip to content

Commit

Permalink
Refactor indirect method dispatch, and make $x.@foo form do something…
Browse files Browse the repository at this point in the history
… along the lines of what we'll eventually want it to.
  • Loading branch information
jnthn committed May 6, 2009
1 parent c38a2ea commit 663cde0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
23 changes: 23 additions & 0 deletions src/builtins/guts.pir
Expand Up @@ -125,6 +125,29 @@ way. Otherwise, it uses .^dispatch from the metaclass.
.end


=item !dispatch_method_indirect

Does an indirect method dispatch.

=cut

.sub '!dispatch_method_indirect'
.param pmc obj
.param pmc methodish
.param pmc pos_args :slurpy
.param pmc name_args :slurpy :named

$P0 = get_hll_global 'Callable'
$I0 = $P0.'ACCEPTS'(methodish)
unless $I0 goto candidate_list
.tailcall methodish(obj, pos_args :flat, name_args :flat :named)

candidate_list:
$P0 = new 'P6Invocation', methodish
$P0(obj, pos_args :flat, name_args :flat :named)
.end


=item !VAR

Helper function for implementing the VAR and .VAR macros.
Expand Down
7 changes: 4 additions & 3 deletions src/parser/actions.pm
Expand Up @@ -1251,11 +1251,12 @@ method dotty($/, $key) {
$past.unshift($past.name());
$past.name('!dispatch_method');
$past.pasttype('call');
$past<invocant_holder> := $past;
}
else {
$past<invocant_holder> := $past;
elsif $<dottyop><methodop><variable> {
$past.name('!dispatch_method_indirect');
$past.pasttype('call');
}
$past<invocant_holder> := $past;

make $past;
}
Expand Down

0 comments on commit 663cde0

Please sign in to comment.