line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Expression::Operator::Binary::Plus; |
2
|
2
|
|
|
2
|
|
881
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
50
|
|
3
|
2
|
|
|
2
|
|
8
|
use utf8; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
9
|
|
4
|
2
|
|
|
2
|
|
40
|
use warnings FATAL => 'all'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
60
|
|
5
|
2
|
|
|
2
|
|
10
|
use parent 'DTL::Fast::Expression::Operator::Binary'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
8
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$DTL::Fast::OPS_HANDLERS{'+'} = __PACKAGE__; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
145
|
use Scalar::Util qw(looks_like_number); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
609
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub dispatch |
12
|
|
|
|
|
|
|
{ |
13
|
81
|
|
|
81
|
0
|
172
|
my ( $self, $arg1, $arg2, $context) = @_; |
14
|
81
|
|
|
|
|
153
|
my ($arg1_type, $arg2_type) = (ref $arg1, ref $arg2); |
15
|
|
|
|
|
|
|
|
16
|
81
|
100
|
100
|
|
|
436
|
if (looks_like_number($arg1) and looks_like_number($arg2)) |
|
|
50
|
33
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
17
|
|
|
|
|
|
|
{ |
18
|
75
|
|
|
|
|
253
|
return $arg1 + $arg2; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
elsif ($arg1_type eq 'ARRAY') |
21
|
|
|
|
|
|
|
{ |
22
|
0
|
0
|
|
|
|
0
|
if ($arg2_type eq 'ARRAY') |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
23
|
|
|
|
|
|
|
{ |
24
|
0
|
|
|
|
|
0
|
return [ @$arg1, @$arg2 ]; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
elsif ($arg2_type eq 'HASH') |
27
|
|
|
|
|
|
|
{ |
28
|
0
|
|
|
|
|
0
|
return [ @$arg1, %$arg2 ]; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
elsif (UNIVERSAL::can($arg2, 'as_array')) |
31
|
|
|
|
|
|
|
{ |
32
|
0
|
|
|
|
|
0
|
return [ @$arg1, @{$arg2->as_array($context)} ]; |
|
0
|
|
|
|
|
0
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
else |
35
|
|
|
|
|
|
|
{ |
36
|
0
|
|
|
|
|
0
|
return [ @$arg1, $arg2 ]; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
elsif ($arg1_type eq 'HASH') |
40
|
|
|
|
|
|
|
{ |
41
|
0
|
0
|
|
|
|
0
|
if ($arg2_type eq 'ARRAY') |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
42
|
|
|
|
|
|
|
{ |
43
|
0
|
|
|
|
|
0
|
return { %$arg1, @$arg2 }; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
elsif ($arg2_type eq 'HASH') |
46
|
|
|
|
|
|
|
{ |
47
|
0
|
|
|
|
|
0
|
return { %$arg1, %$arg2 }; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
elsif (UNIVERSAL::can($arg2, 'as_hash')) |
50
|
|
|
|
|
|
|
{ |
51
|
0
|
|
|
|
|
0
|
return { %$arg1, %{$arg2->as_hash($context)} }; |
|
0
|
|
|
|
|
0
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
else |
54
|
|
|
|
|
|
|
{ |
55
|
0
|
|
0
|
|
|
0
|
die $self->get_render_error( |
|
|
|
0
|
|
|
|
|
56
|
|
|
|
|
|
|
$context, |
57
|
|
|
|
|
|
|
sprintf("don't know how to add %s (%s) to a HASH" |
58
|
|
|
|
|
|
|
, $arg2 // 'undef' |
59
|
|
|
|
|
|
|
, $arg2_type || 'SCALAR' |
60
|
|
|
|
|
|
|
) |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
elsif (UNIVERSAL::can($arg1, 'plus')) |
65
|
|
|
|
|
|
|
{ |
66
|
0
|
|
|
|
|
0
|
return $arg1->plus($arg2, $context); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
elsif ( |
69
|
|
|
|
|
|
|
defined $arg1 |
70
|
|
|
|
|
|
|
and defined $arg2 |
71
|
|
|
|
|
|
|
) |
72
|
|
|
|
|
|
|
{ |
73
|
6
|
|
|
|
|
32
|
return $arg1.$arg2; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
else |
76
|
|
|
|
|
|
|
{ |
77
|
0
|
|
0
|
|
|
|
die $self->get_render_error( |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
78
|
|
|
|
|
|
|
$context, |
79
|
|
|
|
|
|
|
sprintf("don't know how to add %s (%s) to %s (%s)" |
80
|
|
|
|
|
|
|
, $arg1 // 'undef' |
81
|
|
|
|
|
|
|
, $arg1_type || 'SCALAR' |
82
|
|
|
|
|
|
|
, $arg2 // 'undef' |
83
|
|
|
|
|
|
|
, $arg2_type || 'SCALAR' |
84
|
|
|
|
|
|
|
) |
85
|
|
|
|
|
|
|
); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |