line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CljPerl::Seq;
|
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
17
|
use strict;
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
63
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings;
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
42
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1018
|
use CljPerl::Logger;
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
53
|
|
7
|
2
|
|
|
2
|
|
913
|
use CljPerl::Printer;
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1597
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.10';
|
10
|
|
|
|
|
|
|
our $id = 0;
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new {
|
13
|
0
|
|
|
0
|
0
|
|
my $class = shift;
|
14
|
0
|
|
|
|
|
|
my $type = shift;
|
15
|
0
|
0
|
|
|
|
|
$type = "list" if !defined $type;
|
16
|
0
|
|
|
|
|
|
my $value = shift;
|
17
|
0
|
|
|
|
|
|
my @seq = ();
|
18
|
0
|
0
|
|
|
|
|
$value = \@seq if !defined $value;
|
19
|
0
|
|
|
|
|
|
my $self = {class=>"Seq",
|
20
|
|
|
|
|
|
|
type=>$type,
|
21
|
|
|
|
|
|
|
value=>$value,
|
22
|
|
|
|
|
|
|
object_id=>"seq" . ($id++),
|
23
|
|
|
|
|
|
|
meta=>undef,
|
24
|
|
|
|
|
|
|
pos=>{filename=>"unknown",
|
25
|
|
|
|
|
|
|
line=>0,
|
26
|
|
|
|
|
|
|
col=>0}};
|
27
|
0
|
|
|
|
|
|
bless $self;
|
28
|
0
|
|
|
|
|
|
return $self;
|
29
|
|
|
|
|
|
|
}
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub class {
|
32
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
33
|
0
|
|
|
|
|
|
return $self->{class};
|
34
|
|
|
|
|
|
|
}
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub type {
|
37
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
38
|
0
|
|
|
|
|
|
my $type = shift;
|
39
|
0
|
0
|
|
|
|
|
if(defined $type) {
|
40
|
0
|
|
|
|
|
|
$self->{type} = $type;
|
41
|
|
|
|
|
|
|
} else {
|
42
|
0
|
|
|
|
|
|
return $self->{type};
|
43
|
|
|
|
|
|
|
}
|
44
|
|
|
|
|
|
|
}
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub object_id {
|
47
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
48
|
0
|
|
|
|
|
|
return $self->{object_id};
|
49
|
|
|
|
|
|
|
}
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub meta {
|
52
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
53
|
0
|
|
|
|
|
|
my $meta = shift;
|
54
|
0
|
0
|
|
|
|
|
if(defined $meta) {
|
55
|
0
|
|
|
|
|
|
$self->{meta} = $meta;
|
56
|
|
|
|
|
|
|
} else {
|
57
|
0
|
|
|
|
|
|
return $self->{meta};
|
58
|
|
|
|
|
|
|
}
|
59
|
|
|
|
|
|
|
}
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub value {
|
62
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
63
|
0
|
|
|
|
|
|
my $value = shift;
|
64
|
0
|
0
|
|
|
|
|
if(defined $value) {
|
65
|
0
|
|
|
|
|
|
$self->{value} = $value;
|
66
|
|
|
|
|
|
|
} else {
|
67
|
0
|
|
|
|
|
|
return $self->{value};
|
68
|
|
|
|
|
|
|
}
|
69
|
|
|
|
|
|
|
}
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub prepend {
|
72
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
73
|
0
|
|
|
|
|
|
my $v = shift;
|
74
|
0
|
|
|
|
|
|
unshift @{$self->{value}}, $v;
|
|
0
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
}
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub append {
|
78
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
79
|
0
|
|
|
|
|
|
my $v = shift;
|
80
|
0
|
|
|
|
|
|
push @{$self->{value}}, $v;
|
|
0
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
}
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub size {
|
84
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
85
|
0
|
|
|
|
|
|
return scalar @{$self->{value}};
|
|
0
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
}
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub first {
|
89
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
90
|
0
|
0
|
|
|
|
|
return undef if($self->size() < 1);
|
91
|
0
|
|
|
|
|
|
return $self->{value}->[0];
|
92
|
|
|
|
|
|
|
}
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub second {
|
95
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
96
|
0
|
0
|
|
|
|
|
return undef if($self->size() < 2);
|
97
|
0
|
|
|
|
|
|
return $self->{value}->[1];
|
98
|
|
|
|
|
|
|
}
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub third {
|
101
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
102
|
0
|
0
|
|
|
|
|
return undef if($self->size() < 3);
|
103
|
0
|
|
|
|
|
|
return $self->{value}->[2];
|
104
|
|
|
|
|
|
|
}
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub fourth {
|
107
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
108
|
0
|
0
|
|
|
|
|
return undef if($self->size() < 4);
|
109
|
0
|
|
|
|
|
|
return $self->{value}->[3];
|
110
|
|
|
|
|
|
|
}
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub slice {
|
113
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
114
|
0
|
|
|
|
|
|
my @range = @_;
|
115
|
0
|
|
|
|
|
|
return @{$self->{value}}[@range];
|
|
0
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
}
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub each {
|
119
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
120
|
0
|
|
|
|
|
|
my $blk = shift;
|
121
|
0
|
|
|
|
|
|
foreach my $i (@{$self->{value}}) {
|
|
0
|
|
|
|
|
|
|
122
|
0
|
0
|
|
|
|
|
$blk->($i) if defined $i;
|
123
|
|
|
|
|
|
|
}
|
124
|
|
|
|
|
|
|
}
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub show {
|
127
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
128
|
0
|
|
|
|
|
|
my $indent = shift;
|
129
|
0
|
0
|
|
|
|
|
$indent = "" if !defined $indent;
|
130
|
0
|
|
|
|
|
|
print $indent . "type: " . $self->{type} . "\n";
|
131
|
0
|
|
|
|
|
|
print $indent . "(\n";
|
132
|
0
|
|
|
0
|
|
|
$self->each(sub {$_[0]->show($indent . " "); print $indent . " ,\n";});
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
print $indent . ")\n";
|
134
|
|
|
|
|
|
|
}
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub error {
|
137
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
138
|
0
|
|
|
|
|
|
my $msg = shift;
|
139
|
0
|
|
|
|
|
|
$msg .= " [";
|
140
|
0
|
|
|
|
|
|
$msg .= CljPerl::Printer::to_string($self);
|
141
|
0
|
|
|
|
|
|
$msg .= "] @[file: " . $self->{pos}->{filename};
|
142
|
0
|
|
|
|
|
|
$msg .= " ;line: " . $self->{pos}->{line};
|
143
|
0
|
|
|
|
|
|
$msg .= " ;col: " . $self->{pos}->{col} . "]";
|
144
|
0
|
|
|
|
|
|
CljPerl::Logger::error($msg);
|
145
|
|
|
|
|
|
|
}
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
1;
|