line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Expression::Operator::Binary::Div; |
2
|
3
|
|
|
3
|
|
1746
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
78
|
|
3
|
3
|
|
|
3
|
|
14
|
use utf8; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
18
|
|
4
|
3
|
|
|
3
|
|
65
|
use warnings FATAL => 'all'; |
|
3
|
|
|
|
|
174
|
|
|
3
|
|
|
|
|
112
|
|
5
|
3
|
|
|
3
|
|
15
|
use parent 'DTL::Fast::Expression::Operator::Binary'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
16
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$DTL::Fast::OPS_HANDLERS{'/'} = __PACKAGE__; |
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
210
|
use Scalar::Util qw(looks_like_number); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
491
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub dispatch |
12
|
|
|
|
|
|
|
{ |
13
|
46
|
|
|
46
|
0
|
101
|
my ( $self, $arg1, $arg2, $context) = @_; |
14
|
46
|
|
|
|
|
84
|
my ($arg1_type, $arg2_type) = (ref $arg1, ref $arg2); |
15
|
46
|
|
|
|
|
75
|
my $result = 0; |
16
|
|
|
|
|
|
|
|
17
|
46
|
100
|
66
|
|
|
216
|
if (looks_like_number($arg1) and looks_like_number($arg2)) |
|
|
50
|
|
|
|
|
|
18
|
|
|
|
|
|
|
{ |
19
|
44
|
|
|
|
|
87
|
$result = ($arg1 / $arg2); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
elsif (UNIVERSAL::can($arg1, 'div')) |
22
|
|
|
|
|
|
|
{ |
23
|
0
|
|
|
|
|
0
|
$result = $arg1->div($arg2); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
else |
26
|
|
|
|
|
|
|
{ |
27
|
2
|
|
50
|
|
|
34
|
die $self->get_render_error( |
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
28
|
|
|
|
|
|
|
$context, |
29
|
|
|
|
|
|
|
sprintf( |
30
|
|
|
|
|
|
|
"Don't know how to divide %s (%s) by %s (%s)" |
31
|
|
|
|
|
|
|
, $arg1 // 'undef' |
32
|
|
|
|
|
|
|
, $arg1_type || 'SCALAR' |
33
|
|
|
|
|
|
|
, $arg2 // 'undef' |
34
|
|
|
|
|
|
|
, $arg2_type || 'SCALAR' |
35
|
|
|
|
|
|
|
) |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
44
|
|
|
|
|
121
|
return $result; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |