PJVM/Class/Field.pm

filter: Statementstmt 93.9% 31 / 33 Branchbran 25.0% 1 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 3 totaltotal 83.3% 40 / 48 CC 3 SCAR 5.3
CC
3
Cov
86%
new_from_io
3.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.7
« PJVM/Runtime/Native/java/lang/Object.pm ↑ Summary PJVM/Class/Attribute/LineNumberTable.pm »
1 package PJVM::Class::Field;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 ▶use PJVM::Class::Attribute;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 ▶use Object::Tiny qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
11 access_flags
12 name_index
13 descriptor_index
14 attributes
15 parent_class
16 3 );
17  
18 9 ▶sub new_from_io {
Subroutine new_from_io: called CC=3 SCAR=12.0
Pod undocumented
19 9 my ($pkg, $io, $cp, $parent_class) = @_;
20
21 9 my $buff;
22  
23 9 read $io, $buff, 8;
24  
25 9 my ($access_flags, $name_index, $descriptor_index, $attributes_count) = unpack("nnnn", $buff);
26
27 # Read attributes
28 9 my @attributes;
29 9 ▶ if ($attributes_count) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attributes_count) 0 9 9
30 0 ▶ while ($attributes_count--) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attributes_count--) 0 0 0
31 0 push @attributes, PJVM::Class::Attribute->new_from_io($io, $cp);
32 }
33 }
34
35 9 my $self = $pkg->new(
36 access_flags => $access_flags,
37 name_index => $name_index,
38 descriptor_index => $descriptor_index,
39 attributes => \@attributes,
40 parent_class => $parent_class,
41 );
42
43 9 weaken $self->parent_class;
44
45 9 return $self;
46 }
47  
48 3 ▶sub name {
Subroutine name: called CC=1 SCAR=0.0
Pod undocumented
49 3 my $self = shift;
50 3 my $name = $self->parent_class->constant_pool->get($self->name_index);
51 3 return $name->value;
52 }
53  
54 9 ▶sub signature {
Subroutine signature: called CC=1 SCAR=0.0
Pod undocumented
55 9 my $self = shift;
56 9 my $signature = $self->parent_class->constant_pool->get($self->descriptor_index);
57 9 return $signature->value;
58 }
59  
60 3 1;
61 __END__
« PJVM/Runtime/Native/java/lang/Object.pm ↑ Summary PJVM/Class/Attribute/LineNumberTable.pm »