Skip to content

Commit

Permalink
Perlito5 - perl5 - emit function deref
Browse files Browse the repository at this point in the history
  • Loading branch information
fglock committed Aug 26, 2013
1 parent 3958e2f commit a1b4639
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 4 additions & 1 deletion perlito5.pl
Original file line number Diff line number Diff line change
Expand Up @@ -11824,7 +11824,7 @@ package Perlito5::AST::Call;
sub Perlito5::AST::Call::emit_perl5 {
my $self = $_[0];
my $level = $_[1];
my $invocant = $self->{'invocant'}->emit_perl5();
my $invocant = $self->{'invocant'}->emit_perl5(($level + 1));
if (($self->{'method'} eq 'postcircumfix:<[ ]>')) {
return ($invocant . '->[' . $self->{'arguments'}->emit_perl5(($level + 1)) . ']')
};
Expand All @@ -11833,6 +11833,9 @@ package Perlito5::AST::Call;
};
my $meth = $self->{'method'};
if (($meth eq 'postcircumfix:<( )>')) {
if (((ref($self->{'invocant'}) eq 'Perlito5::AST::Var') && ($self->{'invocant'}->{'sigil'} eq '&'))) {
return ($invocant . '(' . join(', ', map($_->emit_perl5(($level + 1)), @{$self->{'arguments'}})) . ')')
};
$meth = ''
};
if ((ref($meth) eq 'Perlito5::AST::Var')) {
Expand Down
11 changes: 9 additions & 2 deletions src5/lib/Perlito5/Perl5/Emitter.pm
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ package Perlito5::AST::Call;
my $self = $_[0];
my $level = $_[1];

my $invocant = $self->{invocant}->emit_perl5;
my $invocant = $self->{invocant}->emit_perl5($level+1);
if ( $self->{method} eq 'postcircumfix:<[ ]>' ) {
return $invocant . '->[' . $self->{arguments}->emit_perl5($level+1) . ']'
}
Expand All @@ -216,7 +216,14 @@ package Perlito5::AST::Call;
}
my $meth = $self->{method};
if ($meth eq 'postcircumfix:<( )>') {
$meth = '';
if ( ref($self->{invocant}) eq 'Perlito5::AST::Var'
&& $self->{invocant}{sigil} eq '&'
)
{
# &subr(args)
return $invocant . '(' . join(', ', map( $_->emit_perl5($level+1), @{$self->{arguments}} )) . ')';
}
$meth = '';
}
if ( ref($meth) eq 'Perlito5::AST::Var' ) {
$meth = $meth->emit_perl5($level+1);
Expand Down

0 comments on commit a1b4639

Please sign in to comment.