line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package UNIVERSAL::Object::Immutable; |
2
|
|
|
|
|
|
|
# ABSTRACT: Another useful base class |
3
|
3
|
|
|
3
|
|
204653
|
use 5.008; |
|
3
|
|
|
|
|
43
|
|
4
|
3
|
|
|
3
|
|
19
|
use strict; |
|
3
|
|
|
|
|
15
|
|
|
3
|
|
|
|
|
83
|
|
5
|
3
|
|
|
3
|
|
24
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
92
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
19
|
use Carp (); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
48
|
|
8
|
3
|
|
|
3
|
|
3553
|
use overload (); |
|
3
|
|
|
|
|
2964
|
|
|
3
|
|
|
|
|
73
|
|
9
|
3
|
|
|
3
|
|
1575
|
use Hash::Util (); |
|
3
|
|
|
|
|
8392
|
|
|
3
|
|
|
|
|
74
|
|
10
|
3
|
|
|
3
|
|
22
|
use Scalar::Util (); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
54
|
|
11
|
|
|
|
|
|
|
|
12
|
3
|
|
|
3
|
|
1259
|
use UNIVERSAL::Object; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
177
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.16'; |
15
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:STEVAN'; |
16
|
|
|
|
|
|
|
|
17
|
3
|
|
|
3
|
|
745
|
our @ISA; BEGIN { @ISA = ('UNIVERSAL::Object') } |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
10
|
|
|
10
|
1
|
478
|
my $class = shift; |
21
|
10
|
|
|
|
|
56
|
my $self = $class->SUPER::new( @_ ); |
22
|
10
|
|
|
|
|
33
|
my $repr = overload::StrVal($self); |
23
|
|
|
|
|
|
|
|
24
|
10
|
100
|
100
|
|
|
179
|
if ( $repr =~ /\=HASH\(0x/ ) { |
|
|
100
|
100
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
25
|
4
|
|
|
|
|
16
|
Hash::Util::lock_hash( %$self ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
elsif ( $repr =~ /\=ARRAY\(0x/ ) { |
28
|
1
|
|
|
|
|
8
|
Internals::SvREADONLY( @$self, 1 ); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
elsif ( $repr =~ /\=SCALAR\(0x/ or $repr =~ /\=REF\(0x/ or $repr =~ /\=REGEXP\(0x/ ) { |
31
|
3
|
|
|
|
|
16
|
Internals::SvREADONLY( $$self, 1 ); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
elsif ( $repr =~ /\=CODE\(0x/ ) { |
34
|
|
|
|
|
|
|
# NOTE: do nothing here, because – ignoring |
35
|
|
|
|
|
|
|
# closures – CODE refs are immutable anyway |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
else { |
38
|
1
|
|
|
|
|
241
|
Carp::confess('Invalid BLESS args for '.Scalar::Util::blessed($self).', unsupported REPR type ('.Scalar::Util::reftype($self).')'); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
9
|
|
|
|
|
111
|
return $self; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |