| 1 | package Scalar::LockRefType; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | ▶ | use 5.010; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 1 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 1 | our $VERSION = '0.03'; | |||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 9 | ▶ | sub TIESCALAR { | ||||||||||||||||||
|
Subroutine
TIESCALAR: called CC=4 SCAR=13.9
| |||||||||||||||||||||
| 11 | 9 | my ($class, $type) = @_; | |||||||||||||||||||
| 12 | 9 | ▶ | return bless { | ||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||
| 13 | value => undef, | ||||||||||||||||||||
| 14 | type => @_ < 2 ? undef | ||||||||||||||||||||
| 15 | : ref($type) ? ref($type) | ||||||||||||||||||||
| 16 | : length($type) ? $type | ||||||||||||||||||||
| 17 | : '' | ||||||||||||||||||||
| 18 | }; | ||||||||||||||||||||
| 19 | } | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 9 | ▶ | sub FETCH { return $_[0]->{value} } | ||||||||||||||||||
|
Subroutine
FETCH: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 8 | ▶ | sub STORE { | ||||||||||||||||||
|
Subroutine
STORE: called CC=4 SCAR=14.0
| |||||||||||||||||||||
| 24 | 8 | my ($self, $value) = @_; | |||||||||||||||||||
| 25 | 8 | ▶ | my $ref = ref $value // ''; | ||||||||||||||||||
|
Condition50%1/2
ref $value // ""
MC/DC0%0/1
ref $value // ""
ref $value
Truth table50%1/2
A
A= ref $value
| |||||||||||||||||||||
| 26 | 8 | ▶ | $self->{type} //= $ref; | ||||||||||||||||||
|
Condition66%2/3
$self->{"type"} //= $ref
MC/DC0%0/2
$self->{"type"} //= $ref
$self->{"type"}
$ref
Truth table66%2/3
A //= B
A= $self->{"type"}B= $ref
| |||||||||||||||||||||
| 27 | 8 | ▶ | croak 'invalid reference type' if $ref ne $self->{type}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 28 | 5 | return $self->{value} = $value; | |||||||||||||||||||
| 29 | } | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | __END__ | ||||||||||||||||||||