line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Moose::Meta::Method::Accessor::Native::String::substr; |
2
|
|
|
|
|
|
|
our $VERSION = '2.2203'; |
3
|
|
|
|
|
|
|
|
4
|
4
|
|
|
4
|
|
2358
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
121
|
|
5
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
104
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
18
|
use Moose::Util (); |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
53
|
|
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
16
|
use Moose::Role; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
28
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
with 'Moose::Meta::Method::Accessor::Native::Reader', |
12
|
|
|
|
|
|
|
'Moose::Meta::Method::Accessor::Native::Writer'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub _generate_method { |
15
|
31
|
|
|
31
|
|
54
|
my $self = shift; |
16
|
|
|
|
|
|
|
|
17
|
31
|
|
|
|
|
55
|
my $inv = '$self'; |
18
|
31
|
|
|
|
|
111
|
my $slot_access = $self->_get_value($inv); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
return ( |
21
|
31
|
|
|
|
|
167
|
'sub {', |
22
|
|
|
|
|
|
|
'my ' . $inv . ' = shift;', |
23
|
|
|
|
|
|
|
$self->_inline_curried_arguments, |
24
|
|
|
|
|
|
|
'if (@_ == 1 || @_ == 2) {', |
25
|
|
|
|
|
|
|
$self->_inline_reader_core($inv, $slot_access), |
26
|
|
|
|
|
|
|
'}', |
27
|
|
|
|
|
|
|
'elsif (@_ == 3) {', |
28
|
|
|
|
|
|
|
$self->_inline_writer_core($inv, $slot_access), |
29
|
|
|
|
|
|
|
'}', |
30
|
|
|
|
|
|
|
'else {', |
31
|
|
|
|
|
|
|
$self->_inline_check_argument_count, |
32
|
|
|
|
|
|
|
'}', |
33
|
|
|
|
|
|
|
'}', |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
93
|
|
|
93
|
|
218
|
sub _minimum_arguments { 1 } |
38
|
93
|
|
|
93
|
|
225
|
sub _maximum_arguments { 3 } |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _inline_process_arguments { |
41
|
62
|
|
|
62
|
|
100
|
my $self = shift; |
42
|
62
|
|
|
|
|
120
|
my ($inv, $slot_access) = @_; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
return ( |
45
|
62
|
|
|
|
|
213
|
'my $offset = shift;', |
46
|
|
|
|
|
|
|
'my $length = @_ ? shift : length ' . $slot_access . ';', |
47
|
|
|
|
|
|
|
'my $replacement = shift;', |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _inline_check_arguments { |
52
|
62
|
|
|
62
|
|
102
|
my $self = shift; |
53
|
62
|
|
|
|
|
100
|
my ($for_writer) = @_; |
54
|
|
|
|
|
|
|
|
55
|
62
|
|
|
|
|
151
|
my @code = ( |
56
|
|
|
|
|
|
|
'if ($offset !~ /^-?\d+$/) {', |
57
|
|
|
|
|
|
|
$self->_inline_throw_exception( InvalidArgumentToMethod => |
58
|
|
|
|
|
|
|
'argument => $offset,'. |
59
|
|
|
|
|
|
|
'ordinal => "first",'. |
60
|
|
|
|
|
|
|
'type_of_argument => "integer",'. |
61
|
|
|
|
|
|
|
'method_name => "substr",'. |
62
|
|
|
|
|
|
|
'type => "Int"', |
63
|
|
|
|
|
|
|
) . ';', |
64
|
|
|
|
|
|
|
'}', |
65
|
|
|
|
|
|
|
'if ($length !~ /^-?\d+$/) {', |
66
|
|
|
|
|
|
|
$self->_inline_throw_exception( InvalidArgumentToMethod => |
67
|
|
|
|
|
|
|
'argument => $length,'. |
68
|
|
|
|
|
|
|
'ordinal => "second",'. |
69
|
|
|
|
|
|
|
'type_of_argument => "integer",'. |
70
|
|
|
|
|
|
|
'method_name => "substr",'. |
71
|
|
|
|
|
|
|
'type => "Int"', |
72
|
|
|
|
|
|
|
) . ';', |
73
|
|
|
|
|
|
|
'}', |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
|
76
|
62
|
100
|
|
|
|
170
|
if ($for_writer) { |
77
|
31
|
|
|
|
|
96
|
push @code, ( |
78
|
|
|
|
|
|
|
'if (!Moose::Util::_STRINGLIKE0($replacement)) {', |
79
|
|
|
|
|
|
|
$self->_inline_throw_exception( InvalidArgumentToMethod => |
80
|
|
|
|
|
|
|
'argument => $replacement,'. |
81
|
|
|
|
|
|
|
'ordinal => "third",'. |
82
|
|
|
|
|
|
|
'type_of_argument => "string",'. |
83
|
|
|
|
|
|
|
'method_name => "substr",'. |
84
|
|
|
|
|
|
|
'type => "Str"', |
85
|
|
|
|
|
|
|
) . ';', |
86
|
|
|
|
|
|
|
'}', |
87
|
|
|
|
|
|
|
); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
62
|
|
|
|
|
271
|
return @code; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub _potential_value { |
94
|
31
|
|
|
31
|
|
53
|
my $self = shift; |
95
|
31
|
|
|
|
|
51
|
my ($slot_access) = @_; |
96
|
|
|
|
|
|
|
|
97
|
31
|
|
|
|
|
94
|
return '(do { ' |
98
|
|
|
|
|
|
|
. 'my $potential = ' . $slot_access . '; ' |
99
|
|
|
|
|
|
|
. '@return = substr $potential, $offset, $length, $replacement; ' |
100
|
|
|
|
|
|
|
. '$potential; ' |
101
|
|
|
|
|
|
|
. '})'; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub _inline_optimized_set_new_value { |
105
|
15
|
|
|
15
|
|
31
|
my $self = shift; |
106
|
15
|
|
|
|
|
41
|
my ($inv, $new, $slot_access) = @_; |
107
|
|
|
|
|
|
|
|
108
|
15
|
|
|
|
|
82
|
return '@return = substr ' . $slot_access . ', ' |
109
|
|
|
|
|
|
|
. '$offset, $length, $replacement;'; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub _return_value { |
113
|
93
|
|
|
93
|
|
133
|
my $self = shift; |
114
|
93
|
|
|
|
|
163
|
my ($slot_access, $for_writer) = @_; |
115
|
|
|
|
|
|
|
|
116
|
93
|
100
|
|
|
|
244
|
return '$return[0]' if $for_writer; |
117
|
|
|
|
|
|
|
|
118
|
62
|
|
|
|
|
278
|
return 'substr ' . $slot_access . ', $offset, $length'; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
4
|
|
|
4
|
|
31
|
no Moose::Role; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
19
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |