line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Moose::Meta::Method::Accessor::Native::String::substr; |
2
|
|
|
|
|
|
|
our $VERSION = '2.2206'; |
3
|
|
|
|
|
|
|
|
4
|
4
|
|
|
4
|
|
2913
|
use strict; |
|
4
|
|
|
|
|
18
|
|
|
4
|
|
|
|
|
148
|
|
5
|
4
|
|
|
4
|
|
32
|
use warnings; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
134
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
21
|
use Moose::Util (); |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
60
|
|
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
18
|
use Moose::Role; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
37
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
with 'Moose::Meta::Method::Accessor::Native::Reader', |
12
|
|
|
|
|
|
|
'Moose::Meta::Method::Accessor::Native::Writer'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub _generate_method { |
15
|
31
|
|
|
31
|
|
68
|
my $self = shift; |
16
|
|
|
|
|
|
|
|
17
|
31
|
|
|
|
|
62
|
my $inv = '$self'; |
18
|
31
|
|
|
|
|
111
|
my $slot_access = $self->_get_value($inv); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
return ( |
21
|
31
|
|
|
|
|
197
|
'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
|
|
266
|
sub _minimum_arguments { 1 } |
38
|
93
|
|
|
93
|
|
305
|
sub _maximum_arguments { 3 } |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _inline_process_arguments { |
41
|
62
|
|
|
62
|
|
132
|
my $self = shift; |
42
|
62
|
|
|
|
|
149
|
my ($inv, $slot_access) = @_; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
return ( |
45
|
62
|
|
|
|
|
238
|
'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
|
|
103
|
my $self = shift; |
53
|
62
|
|
|
|
|
126
|
my ($for_writer) = @_; |
54
|
|
|
|
|
|
|
|
55
|
62
|
|
|
|
|
165
|
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
|
|
|
|
191
|
if ($for_writer) { |
77
|
31
|
|
|
|
|
133
|
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
|
|
|
|
|
360
|
return @code; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub _potential_value { |
94
|
31
|
|
|
31
|
|
64
|
my $self = shift; |
95
|
31
|
|
|
|
|
107
|
my ($slot_access) = @_; |
96
|
|
|
|
|
|
|
|
97
|
31
|
|
|
|
|
136
|
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
|
|
44
|
my $self = shift; |
106
|
15
|
|
|
|
|
59
|
my ($inv, $new, $slot_access) = @_; |
107
|
|
|
|
|
|
|
|
108
|
15
|
|
|
|
|
92
|
return '@return = substr ' . $slot_access . ', ' |
109
|
|
|
|
|
|
|
. '$offset, $length, $replacement;'; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub _return_value { |
113
|
93
|
|
|
93
|
|
550
|
my $self = shift; |
114
|
93
|
|
|
|
|
204
|
my ($slot_access, $for_writer) = @_; |
115
|
|
|
|
|
|
|
|
116
|
93
|
100
|
|
|
|
310
|
return '$return[0]' if $for_writer; |
117
|
|
|
|
|
|
|
|
118
|
62
|
|
|
|
|
337
|
return 'substr ' . $slot_access . ', $offset, $length'; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
4
|
|
|
4
|
|
35
|
no Moose::Role; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
26
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |