Skip to content

Commit

Permalink
Lexical multis now incorporate outer candidates.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Mar 31, 2010
1 parent 872898d commit 6a2e0ae
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Perl6/Actions.pm
Expand Up @@ -978,7 +978,11 @@ method routine_def($/) {
PAST::Op.new( :inline(' %r = new ["Perl6MultiSub"]') ),
$past
);
$symbol_holder.symbol($name, :multis($past))
$symbol_holder.symbol($name, :multis($past));
$past := PAST::Op.new(
:pasttype('callmethod'), :name('incorporate_candidates'),
$past, PAST::Op.new( :pirop('find_lex_skip_current PS'), $name )
);
}
$multi_flag.value($*MULTINESS eq 'proto' ?? 2 !! 1);
}
Expand Down
20 changes: 20 additions & 0 deletions src/pmc/perl6multisub.pmc
Expand Up @@ -1312,6 +1312,26 @@ that we may have in place. Returns SELF.
}
RETURN (PMC *SELF);
}


/*

=item METHOD PMC *incorporate_candidates(PMC *maybe_multi)

Incorporates the given candidates into this multi.

=cut

*/
METHOD PMC *incorporate_candidates(PMC *maybe_multi) {
if (!PMC_IS_NULL(maybe_multi) && VTABLE_isa(interp, maybe_multi, CONST_STRING(interp, "Perl6MultiSub"))) {
INTVAL elements = VTABLE_elements(interp, maybe_multi);
INTVAL i;
for (i = 0; i < elements; i++)
VTABLE_push_pmc(interp, SELF, VTABLE_get_pmc_keyed_int(interp, maybe_multi, i));
}
RETURN (PMC *SELF);
}
}

/*
Expand Down

0 comments on commit 6a2e0ae

Please sign in to comment.