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