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