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