line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: /tree-xpathengine/trunk/lib/Tree/XPathEngine/Literal.pm 17 2006-02-12T08:00:01.814064Z mrodrigu $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Tree::XPathEngine::Literal; |
4
|
5
|
|
|
5
|
|
28
|
use Tree::XPathEngine::Boolean; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
125
|
|
5
|
5
|
|
|
5
|
|
27
|
use Tree::XPathEngine::Number; |
|
5
|
|
|
|
|
17
|
|
|
5
|
|
|
|
|
112
|
|
6
|
5
|
|
|
5
|
|
27
|
use strict; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
275
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use overload |
9
|
5
|
|
|
|
|
52
|
'""' => \&value, |
10
|
5
|
|
|
5
|
|
21383
|
'cmp' => \&xpath_cmp; |
|
5
|
|
|
|
|
6206
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
347
|
|
|
347
|
1
|
10838
|
my $class = shift; |
14
|
347
|
|
|
|
|
678
|
my ($string) = @_; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# $string =~ s/"/"/g; |
17
|
|
|
|
|
|
|
# $string =~ s/'/'/g; |
18
|
|
|
|
|
|
|
|
19
|
347
|
|
|
|
|
2418
|
bless \$string, $class; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub as_string { |
23
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
24
|
0
|
|
|
|
|
0
|
my $string = $$self; |
25
|
0
|
|
|
|
|
0
|
$string =~ s/'/'/g; |
26
|
0
|
|
|
|
|
0
|
return "'$string'"; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub as_xml { |
30
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
31
|
0
|
|
|
|
|
0
|
my $string = $$self; |
32
|
0
|
|
|
|
|
0
|
return "$string\n"; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub value { |
36
|
916
|
|
|
916
|
1
|
5452
|
my $self = shift; |
37
|
916
|
|
|
|
|
4598
|
$$self; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub xpath_cmp { |
41
|
102
|
|
|
102
|
1
|
18800
|
my $self = shift; |
42
|
102
|
|
|
|
|
361
|
my ($cmp, $swap) = @_; |
43
|
102
|
50
|
|
|
|
333
|
if ($swap) { |
44
|
0
|
|
|
|
|
0
|
return $cmp cmp $$self; |
45
|
|
|
|
|
|
|
} |
46
|
102
|
|
|
|
|
1222
|
return $$self cmp $cmp; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub evaluate { |
50
|
521
|
|
|
521
|
1
|
630
|
my $self = shift; |
51
|
521
|
|
|
|
|
1184
|
$self; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub xpath_to_boolean { |
55
|
2
|
|
|
2
|
1
|
3
|
my $self = shift; |
56
|
2
|
100
|
|
|
|
13
|
return (length($$self) > 0) ? Tree::XPathEngine::Boolean->_true : Tree::XPathEngine::Boolean->_false; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
5
|
|
|
5
|
1
|
20
|
sub xpath_to_number { return Tree::XPathEngine::Number->new($_[0]->value); } |
60
|
59
|
|
|
59
|
1
|
212
|
sub xpath_to_literal { return $_[0]; } |
61
|
|
|
|
|
|
|
|
62
|
225
|
|
|
225
|
1
|
491
|
sub xpath_string_value { return $_[0]->value; } |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
__END__ |