line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Expression::Operator::Binary::Mul; |
2
|
2
|
|
|
2
|
|
904
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
49
|
|
3
|
2
|
|
|
2
|
|
9
|
use utf8; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
10
|
|
4
|
2
|
|
|
2
|
|
42
|
use warnings FATAL => 'all'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
56
|
|
5
|
2
|
|
|
2
|
|
9
|
use parent 'DTL::Fast::Expression::Operator::Binary'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
7
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$DTL::Fast::OPS_HANDLERS{'*'} = __PACKAGE__; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
134
|
use Scalar::Util qw(looks_like_number); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
400
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub dispatch |
12
|
|
|
|
|
|
|
{ |
13
|
43
|
|
|
43
|
0
|
92
|
my ( $self, $arg1, $arg2, $context) = @_; |
14
|
43
|
|
|
|
|
86
|
my ($arg1_type, $arg2_type) = (ref $arg1, ref $arg2); |
15
|
43
|
|
|
|
|
72
|
my $result = 0; |
16
|
|
|
|
|
|
|
|
17
|
43
|
100
|
66
|
|
|
236
|
if (looks_like_number($arg1) and looks_like_number($arg2)) |
|
|
50
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
18
|
|
|
|
|
|
|
{ |
19
|
42
|
|
|
|
|
77
|
$result = ($arg1 * $arg2); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
elsif (UNIVERSAL::can($arg1, 'mul')) |
22
|
|
|
|
|
|
|
{ |
23
|
0
|
|
|
|
|
0
|
$result = $arg1->mul($arg2); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
elsif ( |
26
|
|
|
|
|
|
|
defined $arg2 |
27
|
|
|
|
|
|
|
and defined $arg1 |
28
|
|
|
|
|
|
|
and $arg2 =~ /^\d+$/) |
29
|
|
|
|
|
|
|
{ |
30
|
1
|
|
|
|
|
5
|
$result = "$arg1" x $arg2; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
else |
33
|
|
|
|
|
|
|
{ |
34
|
0
|
|
0
|
|
|
0
|
die $self->get_render_error( |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
35
|
|
|
|
|
|
|
$context, |
36
|
|
|
|
|
|
|
sprintf("don't know how to multiplicate %s (%s) to %s (%s)" |
37
|
|
|
|
|
|
|
, $arg1 // 'undef' |
38
|
|
|
|
|
|
|
, $arg1_type || 'SCALAR' |
39
|
|
|
|
|
|
|
, $arg2 // 'undef' |
40
|
|
|
|
|
|
|
, $arg2_type || 'SCALAR' |
41
|
|
|
|
|
|
|
) |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
43
|
|
|
|
|
140
|
return $result; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |