blib/lib/B/Utils/OP.pm

filter: Statementstmt 100% 22 / 22 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 96.4% 27 / 28 CC 1 SCAR 0.0
CC
1
Cov
96%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Utils.xs ↑ Summary
1 package B::Utils::OP;
2  
3 1 require 5.006;
4 1 ▶use Carp 'croak';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use B::Utils ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 our @ISA = 'Exporter';
10 1 require Exporter;
11 1 our $VERSION = '0.29';
12 1 our @EXPORT = qw(parent_op return_op);
13  
14  
15 1 push @ISA, 'DynaLoader';
16 # the boot symbol is in B::Utils. bootstrap doesn't like it, so we
17 # need to load it manually.
18 1 my $bootname = 'boot_B__Utils__OP';
19 1 ▶if (my $boot_symbol_ref = DynaLoader::dl_find_symbol_anywhere($bootname)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $boot_symbol_ref = DynaLoader::dl_find_symbol_anywhere($bootname)) 1 0 1
20 1 DynaLoader::dl_install_xsub(__PACKAGE__."::bootstrap", $boot_symbol_ref, __FILE__)->(__PACKAGE__, $VERSION);
21 }
22  
23 =head1 NAME
24  
25 B::Utils::OP - op related utility functions for perl
26  
27 =head1 VERSION
28  
29 version 0.29
30  
31 =head1 SYNOPSIS
32  
33 use B::Utils::OP qw(parent_op return_op);
34 sub foo {
35 my $pop = parent_op(0);
36 my $rop = return_op(0);
37 }
38  
39 =head1 DESCRIPTION
40  
41 sub foo {
42 dothis(1);
43 find_things();
44 return;
45 }
46  
47 has the following optree:
48  
49 d <1> leavesub[1 ref] K/REFC,1 ->(end)
50 - <@> lineseq KP ->d
51 1 <;> nextstate(main -371 bah.pl:8) v/2 ->2
52 5 <1> entersub[t2] vKS/TARG,3 ->6
53 - <1> ex-list K ->5
54 2 <0> pushmark s ->3
55 3 <$> const[IV 1] sM ->4
56 - <1> ex-rv2cv sK/3 ->-
57 4 <#> gv[*dothis] s ->5
58 6 <;> nextstate(main -371 bah.pl:9) v/2 ->7
59  
60 9 <1> entersub[t4] vKS/TARG,3 ->a
61 - <1> ex-list K ->9
62 7 <0> pushmark s ->8
63 - <1> ex-rv2cv sK/3 ->-
64 8 <#> gv[*find_things] s/EARLYCV ->9
65  
66 a <;> nextstate(main -371 bah.pl:10) v/2 ->b
67 c <@> return K ->d
68 b <0> pushmark s ->c
69  
70 The C<find_things> in C<foo> is called in the C<entersub> in #9. If
71 you call C<parent_op> function with level 0, you get the C<nextstate>
72 op that is before the entersub, which is #6. And C<return_op> gives
73 you the next op that the caller is returning to, in this case, the
74 C<nextstate> in #a.
75  
76 =head2 EXPORTED PERL FUNCTIONS
77  
78 =over
79  
80 =item parent_op($lv)
81  
82 In runtime, returns the L<B::OP> object whose next is the C<entersub> of the current context up level C<$lv>
83  
84 =item return_op($lv)
85  
86 In runtime, returns the L<B::OP> object that the current context is returning to at level C<$lv>
87  
88 =back
89  
90 =head2 B::CV METHODS
91  
92 =over
93  
94 =item $cv->NEW_with_start($root, $start)
95  
96 Clone the C<$cv> but with different C<$root> and C<$start>
97  
98 =back
99  
100 =head1 AUTHORS
101  
102 Chia-liang Kao E<lt>clkao@clkao.orgE<gt>
103  
104 =head1 COPYRIGHT
105  
106 Copyright 2008 by Chia-liang Kao
107  
108 This program is free software; you can redistribute it and/or modify it
109 under the same terms as Perl itself.
110  
111 See L<http://www.perl.com/perl/misc/Artistic.html>
112  
113 =cut
114  
115 1 1;
« Utils.xs ↑ Summary