# keys are addresses of GVs for subs and formats we've already
# deparsed (or at least put into subs_todo)
#
+# subs_declared
+# keys are names of subs for which we've printed declarations.
+# That means we can omit parentheses from the arguments.
+#
# parens: -p
# linenums: -l
# unquote: -q
return "format $name =\n"
. $self->deparse_format($ent->[1]->FORM). "\n";
} else {
+ $self->{'subs_declared'}{$name} = 1;
return "sub $name " . $self->deparse_sub($ent->[1]->CV);
}
}
@text = $op->label . ": " if $op->label;
my $seq = $op->cop_seq;
while (scalar(@{$self->{'subs_todo'}})
- and $seq > $self->{'subs_todo'}[0][0]) {
+ and $seq >= $self->{'subs_todo'}[0][0]) {
push @text, $self->next_todo;
}
my $stash = $op->stashpv;
my $arrow = is_subscriptable($kid->first) ? "" : "->";
$kid = $self->deparse($kid, 24) . $arrow;
}
+
+ # Doesn't matter how many prototypes there are, if
+ # they haven't happened yet!
+ my $declared = exists $self->{'subs_declared'}{$kid};
+
my $args;
- if (defined $proto and not $amper) {
+ if ($declared and defined $proto and not $amper) {
($amper, $args) = $self->check_proto($proto, @exprs);
if ($amper eq "&") {
$args = join(", ", map($self->deparse($_, 6), @exprs));
return $prefix . $amper. $kid;
}
} else {
- if (defined $proto and $proto eq "") {
+ if (!$declared) {
+ return "$kid(" . $args . ")";
+ } elsif (defined $proto and $proto eq "") {
return $kid;
} elsif (defined $proto and $proto eq "\$") {
return $self->maybe_parens_func($kid, $args, $cx, 16);