PJVM/Class/ConstantPool/Types.pm

filter: Statementstmt 90.0% 72 / 80 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 14 / 16 Podpod n/a totaltotal 89.5% 86 / 96 CC 1 SCAR 1.2
CC
1
Cov
90%
new_from_io
2.0
new_from_io
2.0
BEGIN
1.0
CRAP 1.1
« PJVM/Class/Attribute.pm ↑ Summary PJVM/Runtime.pm »
1 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package PJVM::Class::ConstantPool::Base;
5  
6 4 ▶use Object::Tiny qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
7 tag
8 4 );
9  
10 0 ▶sub new_from_io {
Subroutine new_from_io: not called CC=1 SCAR=6.9
11 0 my $pkg = shift;
12 0 die "$pkg does not implement new_from_io";
13 }
14  
15 package PJVM::Class::ConstantPool::Extended;
16 4 our @ISA = qw(PJVM::Class::ConstantPool::Base);
17  
18 package PJVM::Class::ConstantPool::Class;
19 4 our @ISA = qw(PJVM::Class::ConstantPool::Base);
20  
21 4 ▶use Object::Tiny qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
22 name_index
23 4 );
24  
25 12 ▶sub new_from_io {
Subroutine new_from_io: called CC=1 SCAR=0.0
26 12 my ($pkg, $tag, $io) = @_;
27
28 12 my $buff;
29 12 read $io, $buff, 2;
30 12 my ($name_index) = unpack("n", $buff);
31
32 12 my $self = $pkg->new(
33 tag => $tag,
34 name_index => $name_index,
35 );
36
37 12 return $self;
38 }
39  
40 package PJVM::Class::ConstantPool::Long;
41 4 our @ISA = qw(PJVM::Class::ConstantPool::Extended);
42  
43 4 ▶use Object::Tiny qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
44 value
45 4 );
46  
47 4 ▶sub new_from_io {
Subroutine new_from_io: called CC=1 SCAR=0.0
48 4 my ($pkg, $tag, $io) = @_;
49
50 4 my $buff;
51 4 read $io, $buff, 8;
52 4 my ($high, $low) = unpack("NN", $buff);
53
54 4 my $value = ($high * (2**32)) + $low;
55
56 4 my $self = $pkg->new(
57 tag => $tag,
58 value => $value,
59 );
60
61 4 return $self;
62 }
63  
64 package PJVM::Class::ConstantPool::Ref;
65 4 our @isa = qw(PJVM::Class::ConstantPool::Base);
66  
67 4 ▶use Object::Tiny qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
68 tag
69 class_index
70 name_and_type_index
71 4 );
72  
73 4 ▶sub new_from_io {
Subroutine new_from_io: called CC=1 SCAR=0.0
74 4 my ($pkg, $tag, $io) = @_;
75
76 4 my $buff;
77 4 read $io, $buff, 4;
78 4 my ($class_index, $name_and_type_index) = unpack("nn", $buff);
79  
80 4 my $self = $pkg->new(
81 tag => $tag,
82 class_index => $class_index,
83 name_and_type_index => $name_and_type_index,
84 );
85
86 4 return $self;
87 }
88  
89 package PJVM::Class::ConstantPool::FieldRef;
90 4 our @ISA = qw(PJVM::Class::ConstantPool::Ref);
91  
92 package PJVM::Class::ConstantPool::MethodRef;
93 4 our @ISA = qw(PJVM::Class::ConstantPool::Ref);
94  
95 package PJVM::Class::ConstantPool::InterfaceMethodRef;
96 4 our @ISA = qw(PJVM::Class::ConstantPool::Ref);
97  
98 package PJVM::Class::ConstantPool::NameAndType;
99 4 our @ISA = qw(PJVM::Class::ConstantPool::Base);
100  
101 4 ▶use Object::Tiny qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
102 name_index
103 descriptor_index
104 4 );
105  
106 4 ▶sub new_from_io {
Subroutine new_from_io: called CC=1 SCAR=0.0
107 4 my ($pkg, $tag, $io) = @_;
108
109 4 my $buff;
110 4 read $io, $buff, 4;
111 4 my ($name_index, $descriptor_index) = unpack("nn", $buff);
112  
113 4 my $self = $pkg->new(
114 tag => $tag,
115 name_index => $name_index,
116 descriptor_index => $descriptor_index,
117 );
118
119 4 return $self;
120 }
121  
122 package PJVM::Class::ConstantPool::String;
123 4 our @ISA = qw(PJVM::Class::ConstantPool::Base);
124  
125 4 ▶use Object::Tiny qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
126 string_index
127 4 );
128  
129 0 ▶sub new_from_io {
Subroutine new_from_io: not called CC=1 SCAR=6.9
130 0 my ($pkg, $tag, $io) = @_;
131
132 0 my $buff;
133 0 read $io, $buff, 2;
134 0 my ($string_index) = unpack("n", $buff);
135  
136 0 my $self = $pkg->new(
137 tag => $tag,
138 string_index => $string_index,
139 );
140
141 0 return $self;
142 }
143  
144 package PJVM::Class::ConstantPool::Utf8;
145 4 our @ISA = qw(PJVM::Class::ConstantPool::Base);
146  
147 4 ▶use Object::Tiny qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
148 value
149 4 );
150  
151 72 ▶sub new_from_io {
Subroutine new_from_io: called CC=1 SCAR=0.0
152 72 my ($pkg, $tag, $io) = @_;
153
154 72 my $buff;
155 72 read $io, $buff, 2;
156 72 my ($length) = unpack("n", $buff);
157
158 72 read $io, $buff, $length;
159 72 my $str = $buff;
160 72 utf8::upgrade($str);
161
162 72 my $self = $pkg->new(
163 tag => $tag,
164 value => $str,
165 );
166
167 72 return $self;
168 }
169  
170 4 1;
171 __END__
« PJVM/Class/Attribute.pm ↑ Summary PJVM/Runtime.pm »