new switch: don't check prototypes while deparsing
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Sun, 27 Jan 2002 14:51:10 +0000 (15:51 +0100)
committerJarkko Hietaniemi <jhi@iki.fi>
Sun, 27 Jan 2002 15:20:52 +0000 (15:20 +0000)
Message-ID: <20020127145110.A16332@rafael>

p4raw-id: //depot/perl@14440

ext/B/B/Deparse.pm

index a0f0e78..c373a69 100644 (file)
@@ -490,6 +490,8 @@ sub new {
            $self->{'files'}{$1} = 1;
        } elsif ($arg eq "-p") {
            $self->{'parens'} = 1;
+       } elsif ($arg eq "-P") {
+           $self->{'noproto'} = 1;
        } elsif ($arg eq "-l") {
            $self->{'linenums'} = 1;
        } elsif ($arg eq "-q") {
@@ -2779,6 +2781,7 @@ sub method {
 # or ("", $args_after_prototype_demunging) if it does.
 sub check_proto {
     my $self = shift;
+    return "&" if $self->{'noproto'};
     my($proto, @args) = @_;
     my($arg, $real);
     my $doneok = 0;
@@ -3781,6 +3784,22 @@ C<B::Deparse,-p> will print
 which probably isn't what you intended (the C<'???'> is a sign that
 perl optimized away a constant value).
 
+=item B<-P>
+
+Disable prototype checking. With this option, all function calls are
+deparsed as if no prototype was defined for them. In other words,
+
+    perl -MO=Deparse,-P -e 'sub foo (\@) { 1 } foo @x'
+
+will print
+
+    sub foo (\@) {
+       1;
+    }
+    &foo(\@x);
+
+making clear how the parameters are actually passed to C<foo>.
+
 =item B<-q>
 
 Expand double-quoted strings into the corresponding combinations of