Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move invocant adding into sig-object builder.
A small step to prepare for lifting signature creation for method-ish
things earlier.
  • Loading branch information
jnthn committed Feb 24, 2015
1 parent 0caf720 commit 830108d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
12 changes: 2 additions & 10 deletions src/Perl6/Actions.nqp
Expand Up @@ -2967,17 +2967,9 @@ class Perl6::Actions is HLL::Actions does STDActions {

sub methodize_block($/, $code, $past, %sig_info, $invocant_type, :$yada) {
# Get signature and ensure it has an invocant.
my @params := %sig_info<parameters>;
unless @params[0]<is_invocant> {
@params.unshift(hash(
nominal_type => $invocant_type,
is_invocant => 1,
is_multi_invocant => 1
));
}
my $signature := $*W.create_signature_and_params($/, %sig_info, $past, 'Any',
:method);
add_signature_binding_code($past, $signature, @params);
:method, :$invocant_type);
add_signature_binding_code($past, $signature, %sig_info<parameters>);

# Place to store invocant.
$past[0].unshift(QAST::Var.new( :name('self'), :scope('lexical'), :decl('var') ));
Expand Down
9 changes: 8 additions & 1 deletion src/Perl6/World.nqp
Expand Up @@ -1032,10 +1032,17 @@ class Perl6::World is HLL::World {
# for all of the given parameter descriptors. Then make a Signature
# object wrapping them.
method create_signature_and_params($/, %signature_info, $lexpad, $default_type_name,
:$no_attr_check, :$rw, :$method) {
:$no_attr_check, :$rw, :$method, :$invocant_type) {
# If it's a method, add auto-slurpy.
my @params := %signature_info<parameters>;
if $method {
unless @params[0]<is_invocant> {
@params.unshift(hash(
nominal_type => $invocant_type,
is_invocant => 1,
is_multi_invocant => 1
));
}
unless @params[+@params - 1]<named_slurpy> || @params[+@params - 1]<is_capture> {
unless nqp::can($*PACKAGE.HOW, 'hidden') && $*PACKAGE.HOW.hidden($*PACKAGE) {
@params.push(hash(
Expand Down

0 comments on commit 830108d

Please sign in to comment.