File Coverage

blib/lib/Devel/REPL/Plugin/B/Concise.pm
Criterion Covered Total %
statement 20 32 62.5
branch 0 4 0.0
condition n/a
subroutine 7 8 87.5
pod 0 3 0.0
total 27 47 57.4


line stmt bran cond sub pod time code
1 1     1   1245 use strict;
  1         3  
  1         34  
2 1     1   5 use warnings;
  1         2  
  1         79  
3             # ABSTRACT: B::Concise dumping of expression optrees
4              
5             our $VERSION = '1.003029';
6              
7             use Devel::REPL::Plugin;
8 1     1   335 use B::Concise 0.62 ();
  1         3  
  1         6  
9 1     1   6953 use namespace::autoclean;
  1         10091  
  1         40  
10 1     1   10  
  1         2  
  1         14  
11             B::Concise::compileOpts qw(-nobanner);
12              
13             my $self = shift;
14             $self->load_plugin('Turtles');
15 1     1 0 3 }
16 1         7  
17             my $self = shift;
18              
19             my $prefix = $self->default_command_prefix;
20 1     1 0 4  
21             $self->add_turtles_matcher(qr/^
22 1         43 \#(concise) \s+
23             ( (?:\-\w+\s+)* ) # options for concise
24 1         42 (.*) # the code
25             /x);
26             }
27              
28             my ( $self, $eval, $opts, $code ) = @_;
29              
30             die unless $code;
31              
32 0     0 0   my %opts = map { $_ => 1 } (split /\s+/, $opts);
33              
34 0 0         my $sub = $self->compile($code, no_mangling => !delete($opts{"-mangle"}) );
35              
36 0           if ( $self->is_error($sub) ) {
  0            
37             return $self->format($sub);
38 0           } else {
39             open my $fh, ">", \my $out;
40 0 0         {
41 0           local *STDOUT = $fh;
42             B::Concise::compile(keys %opts, $sub)->();
43 0           }
44              
45 0           return $out;
  0            
46 0           }
47             }
48              
49 0           __PACKAGE__
50              
51              
52             =pod
53              
54             =encoding UTF-8
55              
56             =head1 NAME
57              
58             Devel::REPL::Plugin::B::Concise - B::Concise dumping of expression optrees
59              
60             =head1 VERSION
61              
62             version 1.003029
63              
64             =head1 SYNOPSIS
65              
66             repl> #concise -exec -terse {
67             > foo => foo(),
68             > }
69             COP (0x138b1e0) nextstate
70             OP (0x13bd280) pushmark
71             SVOP (0x138c6a0) const PV (0xbbab50) "foo"
72             OP (0x13bbae0) pushmark
73             SVOP (0x13bcee0) gv GV (0xbbb250) *Devel::REPL::Plugin::B::Concise::foo
74             UNOP (0x13890a0) entersub [1]
75             LISTOP (0x13ba020) anonhash
76             UNOP (0x5983d0) leavesub [1]
77              
78             =head1 DESCRIPTION
79              
80             This plugin provides a C<concise> command that uses L<B::Concise> to dump
81             optrees of expressions.
82              
83             The code is not actually executed, which means that when used with
84             L<Deve::REPL::Plugin::OutputCache> there is no new value in C<_>.
85              
86             The command takes the same options as L<B::Concise/compile>, e.g. C<-basic> or
87             C<-exec> to determine the dump order, C<-debug>, C<-concise> and C<-terse> to
88             determine the formatting, etc.
89              
90             =head1 SUPPORT
91              
92             Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Devel-REPL>
93             (or L<bug-Devel-REPL@rt.cpan.org|mailto:bug-Devel-REPL@rt.cpan.org>).
94              
95             There is also an irc channel available for users of this distribution, at
96             L<C<#devel> on C<irc.perl.org>|irc://irc.perl.org/#devel-repl>.
97              
98             =head1 AUTHOR
99              
100             Yuval Kogman E<lt>nothingmuch@woobling.orgE<gt>
101              
102             =head1 COPYRIGHT AND LICENCE
103              
104             This software is copyright (c) 2007 by Matt S Trout - mst (at) shadowcatsystems.co.uk (L<http://www.shadowcatsystems.co.uk/>).
105              
106             This is free software; you can redistribute it and/or modify it under
107             the same terms as the Perl 5 programming language system itself.
108              
109             =cut