line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Expression::Operator::Binary::Mod; |
2
|
2
|
|
|
2
|
|
903
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
47
|
|
3
|
2
|
|
|
2
|
|
10
|
use utf8; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
10
|
|
4
|
2
|
|
|
2
|
|
40
|
use warnings FATAL => 'all'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
56
|
|
5
|
2
|
|
|
2
|
|
8
|
use parent 'DTL::Fast::Expression::Operator::Binary'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
9
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$DTL::Fast::OPS_HANDLERS{mod} = __PACKAGE__; |
8
|
|
|
|
|
|
|
$DTL::Fast::OPS_HANDLERS{'%'} = __PACKAGE__; |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
138
|
use Scalar::Util qw(looks_like_number); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
334
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub dispatch |
13
|
|
|
|
|
|
|
{ |
14
|
44
|
|
|
44
|
0
|
89
|
my ( $self, $arg1, $arg2, $context) = @_; |
15
|
44
|
|
|
|
|
97
|
my ($arg1_type, $arg2_type) = (ref $arg1, ref $arg2); |
16
|
44
|
|
|
|
|
69
|
my $result = 0; |
17
|
|
|
|
|
|
|
|
18
|
44
|
50
|
33
|
|
|
203
|
if (looks_like_number($arg1) and looks_like_number($arg2)) |
|
|
0
|
|
|
|
|
|
19
|
|
|
|
|
|
|
{ |
20
|
44
|
|
|
|
|
92
|
$result = ($arg1 % $arg2); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
elsif (UNIVERSAL::can($arg1, 'mod')) |
23
|
|
|
|
|
|
|
{ |
24
|
0
|
|
|
|
|
0
|
$result = $arg1->mod($arg2); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
else |
27
|
|
|
|
|
|
|
{ |
28
|
0
|
|
0
|
|
|
0
|
die $self->get_render_error( |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
29
|
|
|
|
|
|
|
$context, |
30
|
|
|
|
|
|
|
sprintf("don't know how to take %s (%s) modulus %s (%s)" |
31
|
|
|
|
|
|
|
, $arg1 // 'undef' |
32
|
|
|
|
|
|
|
, $arg1_type || 'SCALAR' |
33
|
|
|
|
|
|
|
, $arg2 // 'undef' |
34
|
|
|
|
|
|
|
, $arg2_type || 'SCALAR' |
35
|
|
|
|
|
|
|
) |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
44
|
|
|
|
|
126
|
return $result; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |