Skip to content

Commit

Permalink
- Improved the deparsing of method calls. (happy 1000 commit)
Browse files Browse the repository at this point in the history
  • Loading branch information
trizen committed Sep 8, 2015
1 parent 376d7bf commit 9dbd336
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lib/Sidef/Deparse/Sidef.pm
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,18 @@ package Sidef::Deparse::Sidef {
foreach my $call (@{$expr->{call}}) {
my $method = $call->{method};

if (ref($method) ne '') {
$method = (
'('
. $self->deparse_expr(
ref($method) eq 'HASH'
? $method
: {self => $method}
)
. ')'
);
}

if ($code eq 'Hash' and $method eq ':') {
$method = 'new';
}
Expand All @@ -434,10 +446,7 @@ package Sidef::Deparse::Sidef {
$code = '(' . $code . ')';
}

if (ref($method) eq 'HASH') {
$code .= '.(' . $self->deparse_expr($method) . ')';
}
elsif ($method =~ /^[[:alpha:]_]/) {
if ($method =~ /^[[:alpha:]_(]/) {
$code .= '.' if $code ne '';
$code .= $method;
}
Expand Down

0 comments on commit 9dbd336

Please sign in to comment.