line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YAX::Node; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
14
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
92
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
17
|
use Scalar::Util qw/weaken refaddr/; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
366
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
1469
|
use YAX::Query; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
85
|
|
8
|
3
|
|
|
3
|
|
18
|
use YAX::Constants qw/:all/; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
567
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use overload |
11
|
3
|
|
|
|
|
31
|
'""' => \&as_string, |
12
|
|
|
|
|
|
|
'<=>' => \&num_cmp, |
13
|
|
|
|
|
|
|
'bool' => \&as_bool, |
14
|
3
|
|
|
3
|
|
4954
|
fallback => 1; |
|
3
|
|
|
|
|
3283
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub NAME () { 0 } |
17
|
|
|
|
|
|
|
sub TYPE () { 1 } |
18
|
|
|
|
|
|
|
sub TEXT () { 2 } |
19
|
|
|
|
|
|
|
sub PRNT () { 3 } |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new { |
22
|
5
|
|
|
5
|
0
|
7
|
my $class = shift; |
23
|
5
|
|
|
|
|
22
|
return bless \[ @_ ], $class; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub name { |
27
|
28
|
|
|
28
|
1
|
38
|
my $self = shift; |
28
|
28
|
|
|
|
|
100
|
$$self->[NAME] |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
sub type { |
31
|
7
|
|
|
7
|
1
|
10
|
my $self = shift; |
32
|
7
|
|
|
|
|
31
|
$$self->[TYPE]; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
sub data { |
35
|
3
|
|
|
3
|
1
|
3
|
my $self = shift; |
36
|
3
|
50
|
|
|
|
5
|
$$self->[TEXT] = shift if @_; |
37
|
3
|
|
|
|
|
10
|
$$self->[TEXT]; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub parent { |
41
|
5
|
|
|
5
|
1
|
7
|
my $self = shift; |
42
|
5
|
50
|
|
|
|
90
|
weaken( $$self->[PRNT] = $_[0] ) if @_; |
43
|
5
|
|
|
|
|
12
|
$$self->[PRNT]; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub num_cmp { |
47
|
0
|
|
|
0
|
0
|
0
|
my ( $a, $b ) = @_; |
48
|
0
|
|
|
|
|
0
|
refaddr( $a ) <=> refaddr( $b ); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub next { |
52
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
53
|
0
|
0
|
|
|
|
0
|
return undef unless $self->parent; |
54
|
0
|
0
|
|
|
|
0
|
return undef if $self->parent->[-1] == $self; |
55
|
0
|
|
|
|
|
0
|
for ( my $x = 0; $x < @{ $self->parent }; $x++ ) { |
|
0
|
|
|
|
|
0
|
|
56
|
0
|
0
|
|
|
|
0
|
if ( $self == $self->parent->[$x] ) { |
57
|
0
|
|
|
|
|
0
|
return $self->parent->[$x+1]; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
0
|
|
|
|
|
0
|
return undef; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub prev { |
64
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
65
|
0
|
0
|
|
|
|
0
|
return undef unless $self->parent; |
66
|
0
|
0
|
|
|
|
0
|
return undef if $self->parent->[0] == $self; |
67
|
0
|
|
|
|
|
0
|
for ( my $x = 0; $x < @{ $self->parent }; $x++ ) { |
|
0
|
|
|
|
|
0
|
|
68
|
0
|
0
|
|
|
|
0
|
if ( $self == $self->parent->[$x] ) { |
69
|
0
|
|
|
|
|
0
|
return $self->parent->[$x-1]; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
0
|
|
|
|
|
0
|
return undef; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub document { |
76
|
3
|
|
|
3
|
1
|
10
|
my $self = shift; |
77
|
3
|
|
|
|
|
4
|
my $root = $self; |
78
|
3
|
|
|
|
|
7
|
while ( $root->parent ) { |
79
|
6
|
|
|
|
|
14
|
$root = $root->parent; |
80
|
6
|
100
|
|
|
|
15
|
return $root if $root->type == DOCUMENT_NODE; |
81
|
|
|
|
|
|
|
} |
82
|
0
|
|
|
|
|
0
|
return ( ); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub as_string { |
86
|
2
|
|
|
2
|
1
|
2
|
my $self = shift; |
87
|
2
|
50
|
|
|
|
5
|
if ( $self->type == COMMENT_NODE ) { |
88
|
0
|
|
|
|
|
0
|
return ''; |
89
|
|
|
|
|
|
|
} |
90
|
2
|
50
|
|
|
|
3
|
if ( $self->type == CDATA_SECTION_NODE ) { |
91
|
2
|
|
|
|
|
12
|
return 'data.']]>'; |
92
|
|
|
|
|
|
|
} |
93
|
0
|
0
|
|
|
|
0
|
if ( $self->type == PROCESSING_INSTRUCTION_NODE ) { |
94
|
0
|
|
|
|
|
0
|
return ''.$self->name.' '.$self->data.' ?>'; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# prevent stringification when in a boolean context |
99
|
12
|
|
|
12
|
0
|
185
|
sub as_bool { 1 } |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
102
|
|
|
|
|
|
|
__END__ |