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