File Coverage

blib/lib/CPU/x86_64/InstructionWriter/Label.pm
Criterion Covered Total %
statement 9 18 50.0
branch 0 12 0.0
condition 0 3 0.0
subroutine 3 7 42.8
pod 3 4 75.0
total 15 44 34.0


line stmt bran cond sub pod time code
1             package CPU::x86_64::InstructionWriter::Label;
2             our $VERSION = '0.001'; # VERSION
3 17     17   110 use strict;
  17         35  
  17         466  
4 17     17   104 use warnings;
  17         32  
  17         357  
5 17     17   81 use Carp;
  17         34  
  17         4579  
6              
7             # ABSTRACT: Object representing a jump target in the code
8              
9              
10 0 0   0 1   sub relative_to { @_ > 1 && carp "Read-only"; $_[0]{relative_to} }
  0            
11 0 0   0 1   sub name { @_ > 1 && carp "Read-only"; $_[0]{name} }
  0            
12 0 0   0 1   sub offset { @_ > 1 && carp "Read-only"; $_[0]{offset} }
  0            
13             sub value {
14 0     0 0   my $offset= $_[0]{offset};
15             my $rel= !defined $_[0]{relative_to}? 0
16             : ref $_[0]{relative_to}? $_[0]{relative_to}->value
17 0 0         : $_[0]{relative_to};
    0          
18 0 0 0       defined $offset && defined $rel? $offset + $rel : undef;
19             }
20              
21              
22             1;
23              
24             __END__