line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: Logical.pm,v 1.13 2004/06/11 21:50:53 claes Exp $ |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
31
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
4516
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = "1.00"; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Array::Stream::Transactional::Matcher::Logical; |
8
|
|
|
|
|
|
|
our @ISA = qw(Array::Stream::Transactional::Matcher::Rule); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
6
|
|
|
6
|
1
|
15
|
my ($class, @args) = @_; |
12
|
6
|
|
33
|
|
|
36
|
$class = ref $class || $class; |
13
|
6
|
|
|
|
|
63
|
bless [@args], $class; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub match { |
17
|
0
|
|
|
0
|
0
|
0
|
1; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
package Array::Stream::Transactional::Matcher::Logical::and; |
21
|
|
|
|
|
|
|
our @ISA = qw(Array::Stream::Transactional::Matcher::Logical); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub match { |
24
|
5
|
|
|
5
|
|
10
|
my ($self, $stream, @passthru) = @_; |
25
|
|
|
|
|
|
|
|
26
|
5
|
|
|
|
|
14
|
$stream->commit; |
27
|
5
|
|
|
|
|
40
|
my $match = 0; |
28
|
5
|
|
|
|
|
12
|
my $start_pos = $stream->pos; |
29
|
5
|
|
|
|
|
17
|
my $end_pos = $start_pos; |
30
|
5
|
50
|
|
|
|
22
|
if(@$self) { |
31
|
5
|
|
|
|
|
8
|
RULES: foreach my $rule (@$self) { |
32
|
8
|
|
|
|
|
35
|
$match = $rule->match($stream, @passthru); |
33
|
8
|
100
|
|
|
|
21
|
unless($match) { |
34
|
4
|
|
|
|
|
12
|
$stream->rollback; |
35
|
4
|
|
|
|
|
42
|
return 0; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
4
|
50
|
|
|
|
13
|
if($stream->pos > $end_pos) { |
39
|
0
|
|
|
|
|
0
|
$end_pos = $stream->pos; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
7
|
$stream->rollback; |
45
|
1
|
|
|
|
|
9
|
my $move = $end_pos - $start_pos; |
46
|
1
|
|
|
|
|
6
|
$stream->next while($move--); |
47
|
1
|
|
|
|
|
3
|
return $match; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
package Array::Stream::Transactional::Matcher::Logical::or; |
51
|
|
|
|
|
|
|
our @ISA = qw(Array::Stream::Transactional::Matcher::Logical); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub match { |
54
|
22
|
|
|
22
|
|
52
|
my ($self, $stream, @passthru) = @_; |
55
|
|
|
|
|
|
|
|
56
|
22
|
|
|
|
|
56
|
$stream->commit; |
57
|
|
|
|
|
|
|
|
58
|
22
|
50
|
|
|
|
204
|
if(@$self) { |
59
|
22
|
|
|
|
|
28
|
my $match = 0; |
60
|
22
|
|
|
|
|
37
|
RULES: foreach my $rule (@$self) { |
61
|
38
|
|
|
|
|
103
|
$match = $rule->match($stream, @passthru); |
62
|
38
|
100
|
|
|
|
108
|
if($match) { |
63
|
9
|
|
|
|
|
29
|
$stream->regret; |
64
|
9
|
|
|
|
|
91
|
return $match; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
13
|
|
|
|
|
42
|
$stream->rollback; |
71
|
13
|
|
|
|
|
135
|
return 0; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
package Array::Stream::Transactional::Matcher::Logical::xor; |
75
|
|
|
|
|
|
|
our @ISA = qw(Array::Stream::Transactional::Matcher::Logical); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub match { |
78
|
5
|
|
|
5
|
|
9
|
my ($self, $stream, @passthru) = @_; |
79
|
|
|
|
|
|
|
|
80
|
5
|
|
|
|
|
12
|
$stream->commit; |
81
|
|
|
|
|
|
|
|
82
|
5
|
|
|
|
|
32
|
my $match = 1; |
83
|
5
|
50
|
|
|
|
20
|
if (@$self) { |
84
|
5
|
|
|
|
|
10
|
my @rules = @$self; |
85
|
5
|
|
|
|
|
17
|
$match = $rules[0]->match($stream); |
86
|
5
|
|
|
|
|
15
|
@rules = @rules[1..$#rules]; |
87
|
5
|
|
|
|
|
10
|
RULES: foreach my $rule (@rules) { |
88
|
5
|
|
|
|
|
15
|
my $next = $rule->match($stream, @passthru); |
89
|
5
|
100
|
|
|
|
22
|
unless(abs($match) ^ abs($next)) { |
90
|
3
|
|
|
|
|
8
|
$stream->rollback; |
91
|
3
|
|
|
|
|
33
|
return 0; |
92
|
|
|
|
|
|
|
} |
93
|
2
|
|
|
|
|
11
|
$stream->commit; |
94
|
2
|
|
|
|
|
15
|
$match ^= abs($next); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
2
|
50
|
|
|
|
8
|
unless($match) { |
99
|
0
|
|
|
|
|
0
|
$stream->rollback; |
100
|
0
|
|
|
|
|
0
|
return 0; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
2
|
|
|
|
|
6
|
$stream->regret; |
104
|
2
|
|
|
|
|
17
|
return $match; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
package Array::Stream::Transactional::Matcher::Logical::not; |
108
|
|
|
|
|
|
|
our @ISA = qw(Array::Stream::Transactional::Matcher::Logical); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub match { |
111
|
5
|
|
|
5
|
|
11
|
my ($self, $stream, @passthru) = @_; |
112
|
|
|
|
|
|
|
|
113
|
5
|
|
|
|
|
56
|
$stream->commit; |
114
|
|
|
|
|
|
|
|
115
|
5
|
|
|
|
|
45
|
my $match = 1; |
116
|
5
|
50
|
|
|
|
21
|
if(@$self) { |
117
|
5
|
|
|
|
|
10
|
RULES: foreach my $rule (@$self) { |
118
|
5
|
|
|
|
|
17
|
$match = $rule->match($stream, @passthru); |
119
|
5
|
100
|
|
|
|
17
|
if($match) { |
120
|
1
|
|
|
|
|
5
|
$stream->rollback; |
121
|
1
|
|
|
|
|
12
|
return 0; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
4
|
|
|
|
|
20
|
$stream->regret; |
127
|
4
|
|
|
|
|
38
|
return 1; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
1; |
131
|
|
|
|
|
|
|
__END__ |