File Coverage

blib/lib/B/Utils1/OP.pm
Criterion Covered Total %
statement 3 3 100.0
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 4 4 100.0


line stmt bran cond sub pod time code
1             package B::Utils1::OP;
2              
3             require 5.006;
4 1     1   3821 use B::Utils1 ();
  1         2  
  1         70  
5              
6             our @ISA = 'Exporter';
7             require Exporter;
8             our $VERSION = '1.05';
9             our @EXPORT = qw(parent_op return_op);
10              
11             =head1 NAME
12              
13             B::Utils1::OP - op related utility functions for perl
14              
15             =head1 SYNOPSIS
16              
17             use B::Utils1::OP qw(parent_op return_op);
18             sub foo {
19             my $pop = parent_op(0);
20             my $rop = return_op(0);
21             }
22              
23             =head1 DESCRIPTION
24              
25             sub foo {
26             dothis(1);
27             find_things();
28             return;
29             }
30              
31             has the following optree:
32              
33             d <1> leavesub[1 ref] K/REFC,1 ->(end)
34             - <@> lineseq KP ->d
35             1 <;> nextstate(main -371 bah.pl:8) v/2 ->2
36             5 <1> entersub[t2] vKS/TARG,3 ->6
37             - <1> ex-list K ->5
38             2 <0> pushmark s ->3
39             3 <$> const[IV 1] sM ->4
40             - <1> ex-rv2cv sK/3 ->-
41             4 <#> gv[*dothis] s ->5
42             6 <;> nextstate(main -371 bah.pl:9) v/2 ->7
43              
44             9 <1> entersub[t4] vKS/TARG,3 ->a
45             - <1> ex-list K ->9
46             7 <0> pushmark s ->8
47             - <1> ex-rv2cv sK/3 ->-
48             8 <#> gv[*find_things] s/EARLYCV ->9
49              
50             a <;> nextstate(main -371 bah.pl:10) v/2 ->b
51             c <@> return K ->d
52             b <0> pushmark s ->c
53              
54             The C in C is called in the C in #9. If
55             you call C function with level 0, you get the C
56             op that is before the entersub, which is #6. And C gives
57             you the next op that the caller is returning to, in this case, the
58             C in #a.
59              
60             =head2 EXPORTED PERL FUNCTIONS
61              
62             =over
63              
64             =item parent_op($lv)
65              
66             In runtime, returns the L object whose next is the C of the current context up level C<$lv>
67              
68             =item return_op($lv)
69              
70             In runtime, returns the L object that the current context is returning to at level C<$lv>
71              
72             =back
73              
74             =head1 AUTHORS
75              
76             Chia-liang Kao Eclkao@clkao.orgE
77              
78             =head1 COPYRIGHT
79              
80             Copyright 2008 by Chia-liang Kao
81              
82             This program is free software; you can redistribute it and/or modify it
83             under the same terms as Perl itself.
84              
85             See L
86              
87             =cut
88              
89             1;