line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Expression::Operator::Binary::Minus; |
2
|
2
|
|
|
2
|
|
903
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
49
|
|
3
|
2
|
|
|
2
|
|
10
|
use utf8; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
8
|
|
4
|
2
|
|
|
2
|
|
44
|
use warnings FATAL => 'all'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
55
|
|
5
|
2
|
|
|
2
|
|
10
|
use parent 'DTL::Fast::Expression::Operator::Binary'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
10
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$DTL::Fast::OPS_HANDLERS{'-'} = __PACKAGE__; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
143
|
use Scalar::Util qw(looks_like_number); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
343
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub dispatch |
12
|
|
|
|
|
|
|
{ |
13
|
42
|
|
|
42
|
0
|
86
|
my ( $self, $arg1, $arg2, $context) = @_; |
14
|
42
|
|
|
|
|
79
|
my ($arg1_type, $arg2_type) = (ref $arg1, ref $arg2); |
15
|
|
|
|
|
|
|
|
16
|
42
|
50
|
33
|
|
|
197
|
if (looks_like_number($arg1) and looks_like_number($arg2)) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
17
|
|
|
|
|
|
|
{ |
18
|
42
|
|
|
|
|
170
|
return $arg1 - $arg2; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
elsif ($arg1_type eq 'ARRAY') # @todo array substitution |
21
|
|
|
|
|
|
|
{ |
22
|
0
|
|
|
|
|
|
die $self->get_render_error( $context, 'arrays substitution not yet implemented'); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
elsif ($arg1_type eq 'HASH') # @todo hash substitution |
25
|
|
|
|
|
|
|
{ |
26
|
0
|
|
|
|
|
|
die $self->get_render_error( $context, 'hashes substitution not yet implemented'); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
elsif (UNIVERSAL::can($arg1, 'minus')) |
29
|
|
|
|
|
|
|
{ |
30
|
0
|
|
|
|
|
|
return $arg1->minus($arg2); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
else |
33
|
|
|
|
|
|
|
{ |
34
|
0
|
|
0
|
|
|
|
die $self->get_render_error( |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
35
|
|
|
|
|
|
|
$context, |
36
|
|
|
|
|
|
|
sprintf("don't know how to substitute %s (%s) from %s (%s)" |
37
|
|
|
|
|
|
|
, $arg1 // 'undef' |
38
|
|
|
|
|
|
|
, $arg1_type || 'SCALAR' |
39
|
|
|
|
|
|
|
, $arg2 // 'undef' |
40
|
|
|
|
|
|
|
, $arg2_type || 'SCALAR' |
41
|
|
|
|
|
|
|
) |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |