line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CIAO::Lib::StackIO; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
27504
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
31
|
|
5
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
486
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require XSLoader; |
11
|
|
|
|
|
|
|
XSLoader::load('CIAO::Lib::StackIO', $VERSION); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Preloaded methods go here. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our %Options = ( prepend => 1, expand => 1 ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new |
18
|
|
|
|
|
|
|
{ |
19
|
6
|
|
|
6
|
1
|
46369
|
my $class = shift; |
20
|
6
|
|
|
|
|
15
|
my $list = shift; |
21
|
6
|
|
100
|
|
|
44
|
my $opts = shift || { prepend => 1, expand => 0 }; |
22
|
|
|
|
|
|
|
|
23
|
6
|
50
|
|
|
|
24
|
croak( __PACKAGE__, ": options must be hash ref\n" ) |
24
|
|
|
|
|
|
|
unless 'HASH' eq ref $opts; |
25
|
|
|
|
|
|
|
|
26
|
6
|
50
|
|
|
|
16
|
croak( __PACKAGE__, ": extra arguments to constructor\n" ) |
27
|
|
|
|
|
|
|
if @_; |
28
|
|
|
|
|
|
|
|
29
|
6
|
|
|
|
|
22
|
my @badopts = grep { ! exists $Options{lc $_ } } keys %$opts; |
|
10
|
|
|
|
|
40
|
|
30
|
6
|
50
|
|
|
|
16
|
croak( __PACKAGE__, ": unknown options: ", join(', ', @badopts ) ) |
31
|
|
|
|
|
|
|
if @badopts; |
32
|
|
|
|
|
|
|
|
33
|
6
|
|
|
|
|
16
|
my %opts = map { lc $_ => $opts->{$_} } keys %$opts; |
|
10
|
|
|
|
|
38
|
|
34
|
|
|
|
|
|
|
|
35
|
6
|
|
|
|
|
14
|
my $stack; |
36
|
6
|
100
|
100
|
|
|
38
|
if ( exists $opts{expand} && $opts{expand} ) |
37
|
|
|
|
|
|
|
{ |
38
|
1
|
50
|
|
|
|
54
|
$stack = |
39
|
|
|
|
|
|
|
CIAO::Lib::StackIO::Private::stk_expand_n( $list, $opts{expand} ) |
40
|
|
|
|
|
|
|
or croak( __PACKAGE__, ": error generating expanded stack\n" ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
else |
43
|
|
|
|
|
|
|
{ |
44
|
5
|
100
|
66
|
|
|
465
|
$stack = ( exists $opts{prepend} && $opts{prepend} ) ? |
45
|
|
|
|
|
|
|
CIAO::Lib::StackIO::Private::stk_build( $list ) : |
46
|
|
|
|
|
|
|
CIAO::Lib::StackIO::Private::stk_build_gen( $list ); |
47
|
|
|
|
|
|
|
|
48
|
5
|
50
|
|
|
|
24
|
croak( __PACKAGE__, ": error building stack\n" ) |
49
|
|
|
|
|
|
|
unless $stack; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# force a stack rewind because of a bug in the stackio library when |
53
|
|
|
|
|
|
|
# creating empty stacks. |
54
|
6
|
|
|
|
|
24
|
$stack->rewind; |
55
|
|
|
|
|
|
|
|
56
|
6
|
|
|
|
|
29
|
$stack; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |